Constructor
new Line(a, b)
Create a line between two Vectors.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
a | Vector | The startpoint. | ||
b | Vector | The endpoint. | ||
options.stroke | string | <optional> | "black" | |
options.strokeWidth | number | <optional> | 0.1 |
Classes
Methods
intersects(target) → {boolean|Array}
Check if this line intersects another shape. Currently only Line is supported.
Name | Type | Description |
---|---|---|
target | object | The target. |
- False if lines don't intersect, otherwise returns the intersection point [x,y]
- Type:
- boolean |
Array
isContainedBy(line) → {boolean}
Check if this line lies directly on top of a longer line.
Name | Type | Description |
---|---|---|
line | Line | The target line to check against. |
- True if this line's startpoint and endpoint are both on the line being checked against, otherwise False.
- Type:
- boolean
isDuplicate(line) → {boolean}
Check if this line is the same as another line.
Name | Type | Description |
---|---|---|
line | Line | The target line to compare to. |
True if startpoints and endpoints are identical or in reverse.
- Type:
- boolean
length() → {number}
Get the length.
The distance from the startpoint to the endpoint. Uses the Vector#distance method.
- Type:
- number
toSVGElement() → {SVGElement}
- Type:
- SVGElement
(static) fromArray(array) → {Line}
Create a Line from an array of numbers.
Name | Type | Description |
---|---|---|
array | Array.<number> | [x1, y1, x2, y2]. |
- Type:
- Line
(static) lineIntersection(line1, line2) → {boolean|Array}
Check if two lines intersect.
- False if lines don't intersect, otherwise returns the intersection point [x,y]
- Type:
- boolean |
Array