Shaku

Shaku JS

Back To Table of Content

Line

Line

Implement a simple 2d Line.

Kind: global class

new Line(from, to)

Create the Line.

Param Type Description
from Vector2 Line start position.
to Vector2 Line end position.

line.clone() ⇒ Line

Return a clone of this line.

Kind: instance method of Line
Returns: Line - Cloned line.

line.toDict(minimized) ⇒ \*

Convert to dictionary.

Kind: instance method of Line
Returns: \* - Dictionary with {from, to}.

Param Type Description
minimized Boolean If true, will not include keys that their values are 0. You can use fromDict on minimized dicts.

line.containsVector(p, threshold) ⇒ Boolean

Check if this circle contains a Vector2.

Kind: instance method of Line
Returns: Boolean - if point is contained within the circle.

Param Type Description
p Vector2 Point to check.
threshold Number Distance between point and line to consider as intersecting. Default is 0.5, meaning it will treat point and line as round integers (sort-of).

line.collideLine(other) ⇒ Boolean

Check if this line collides with another line.

Kind: instance method of Line
Returns: Boolean - True if lines collide, false otherwise.

Param Type Description
other Line Other line to test collision with.

line.distanceToVector(v) ⇒ Number

Get the shortest distance between this line segment and a vector.

Kind: instance method of Line
Returns: Number - Shortest distance between line and vector.

Param Type Description
v Vector2 Vector to get distance to.

line.equals(other) ⇒ Boolean

Check if equal to another circle.

Kind: instance method of Line
Returns: Boolean - True if circles are equal, false otherwise.

Param Type Description
other Circle Other circle to compare to.

Line.fromDict(data) ⇒ Line

Create Line from a dictionary.

Kind: static method of Line
Returns: Line - Newly created line.

Param Type Description
data \* Dictionary with {from, to}.

Line.lerp(l1, l2, a) ⇒ Line

Lerp between two lines.

Kind: static method of Line
Returns: Line - result lines.

Param Type Description
l1 Line First lines.
l2 Line Second lines.
a Number Lerp factor (0.0 - 1.0).