A line can either be defined as two points p1 and p2, or
a single point p1, a length and an angle.
The line has some width that will be filled on both sides
of the line points evenly ('mid'), or on one side only.
The line's 'positive' side is the side to which it rotates toward
when rotating in the positive angle direction around p1.
Similarly the line's 'negative' side is the opposite.
The line can be solid or dashed using the dash property.
The line can have arrows at one or both ends using the arrow property.
widthIsnumber | positive | negative | mid — defines how the width is grown from the polyline's points.
Only "mid" is fully compatible with all options in
arrow. ("mid")
dashTypeDash — leave empty for solid line - use array of
numbers for dash line where first number is length of line, second number is
length of gap and then the pattern repeats - can use more than one dash length
and gap - e.g. [0.1, 0.01, 0.02, 0.01] produces a lines with a long dash,
short gap, short dash, short gap and then repeats.
arrowOBJ_LineArrows | TypeArrowHead — either an object defining custom
arrows or a string representing the name of an arrow head style can be used.
If a string is used, then the line will have an arrow at both ends.
Arrows are only available for widthIs: 'mid' and linePrimitives: false
linePrimitivesboolean — Use WebGL line primitives instead of
triangle primitives to draw the line (false)
lineNumnumber — Number of line primitives to use when
linePrimitivs: true (2)
drawBorderBuffer(number | TypeParsableBorder) & TypeParsableBorder — override OBJ_Generic drawBorderBuffer with number to make the
drawBorderBuffer the same as the line with additional number thickness
on each side and the ends (0)
// Simple line defined by two points figure.add({ name:'l', make:'line', p1: [0, 0], p2: [0, 1], width:0.02, });
Example
// Dashed line defined by a point, a length and an angle figure.add({ name:'l', make:'line', p1: [0, 0], length:1, angle:Math.PI / 2, width:0.03, dash: [0.1, 0.02, 0.03, 0.02], });
Example
// Line with two different arrows on ends figure.add({ name:'l', make:'line', p1: [0, 0], p2: [0, 1], width:0.03, arrow: { start:'rectangle', end:'barb', }, }); @interface
Line definition options object that extends OBJ_Generic (without
drawType) and OBJ_FigurePrimitiveA line can either be defined as two points
p1andp2, or a single pointp1, alengthand anangle.The line has some
widththat will be filled on both sides of the line points evenly ('mid'), or on one side only. The line's'positive'side is the side to which it rotates toward when rotating in the positive angle direction aroundp1. Similarly the line's'negative'side is the opposite.The line can be solid or dashed using the
dashproperty.The line can have arrows at one or both ends using the
arrowproperty.p1TypeParsablePoint — start point of linep2TypeParsablePoint — end point of linelengthnumber— length of line fromp1anglenumber— angle of line fromp1widthnumber— (0.01)widthIsnumber|positive|negative|mid— defines how the width is grown from the polyline's points. Only"mid"is fully compatible with all options inarrow. ("mid")dashTypeDash — leave empty for solid line - use array of numbers for dash line where first number is length of line, second number is length of gap and then the pattern repeats - can use more than one dash length and gap - e.g. [0.1, 0.01, 0.02, 0.01] produces a lines with a long dash, short gap, short dash, short gap and then repeats.arrowOBJ_LineArrows | TypeArrowHead — either an object defining custom arrows or a string representing the name of an arrow head style can be used. If a string is used, then the line will have an arrow at both ends. Arrows are only available forwidthIs: 'mid'andlinePrimitives: falselinePrimitivesboolean— Use WebGL line primitives instead of triangle primitives to draw the line (false)lineNumnumber— Number of line primitives to use whenlinePrimitivs:true(2)drawBorderBuffer(number | TypeParsableBorder) & TypeParsableBorder— override OBJ_GenericdrawBorderBufferwithnumberto make the drawBorderBuffer the same as the line with additionalnumberthickness on each side and the ends (0)See
To test examples, append them to the boilerplate
Example
Example
Example