Constructor
new Line(a, b)
Create a line between two Vectors.
Parameters:
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.
Parameters:
Name | Type | Description |
---|---|---|
target | object | The target. |
Returns:
- 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.
Parameters:
Name | Type | Description |
---|---|---|
line | Line | The target line to check against. |
Returns:
- 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.
Parameters:
Name | Type | Description |
---|---|---|
line | Line | The target line to compare to. |
Returns:
True if startpoints and endpoints are identical or in reverse.
- Type:
- boolean
length() → {number}
Get the length.
Returns:
The distance from the startpoint to the endpoint. Uses the Vector#distance method.
- Type:
- number
toSVGElement() → {SVGElement}
Returns:
- Type:
- SVGElement
(static) fromArray(array) → {Line}
Create a Line from an array of numbers.
Parameters:
Name | Type | Description |
---|---|---|
array | Array.<number> | [x1, y1, x2, y2]. |
Returns:
- Type:
- Line
(static) lineIntersection(line1, line2) → {boolean|Array}
Check if two lines intersect.
Returns:
- False if lines don't intersect, otherwise returns the intersection point [x,y]
- Type:
- boolean |
Array