# Two.Path
Extends: Two.Shape
This is the primary primitive class for creating all drawable shapes in Two.js. Unless specified methods return their instance of Two.Path
for the purpose of chaining.
# Constructor
Argument | Description |
---|---|
vertices | A list of Two.Anchors that represent the order and coordinates to construct the rendered shape. |
closed | Describes whether the shape is closed or open. |
curved | Describes whether the shape automatically calculates bezier handles for each vertex. |
manual | Describes whether the developer controls how vertices are plotted or if Two.js automatically plots coordinates based on closed and curved booleans. |
# closed
Two.Path.closed
Determines whether a final line is drawn between the final point in the vertices
array and the first point.
# curved
Two.Path.curved
When the path is automatic = true
this boolean determines whether the lines between the points are curved or not.
# beginning
Two.Path.beginning
Number between zero and one to state the beginning of where the path is rendered.
Two.Path.beginning is a percentage value that represents at what percentage into the path should the renderer start drawing.
# ending
Two.Path.ending
Number between zero and one to state the ending of where the path is rendered.
Two.Path.ending is a percentage value that represents at what percentage into the path should the renderer start drawing.
# fill
Two.Path.fill
The value of what the path should be filled in with.
See: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value (opens new window) for more information on CSS's colors as String
.
# stroke
Two.Path.stroke
The value of what the path should be outlined in with.
See: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value (opens new window) for more information on CSS's colors as String
.
# className
Two.Path.className
A class to be applied to the element to be compatible with CSS styling.
# cap
Two.Path.cap
# join
Two.Path.join
# miter
Two.Path.miter
# vertices
Two.Path.vertices
An ordered list of anchor points for rendering the path.
A list of Two.Anchor objects that consist of what form the path takes.
# automatic
Two.Path.automatic
Determines whether or not Two.js should calculate curves, lines, and commands automatically for you or to let the developer manipulate them for themselves.
# dashes
Two.Path.dashes
Array of numbers. Odd indices represent dash length. Even indices represent dash space.
A list of numbers that represent the repeated dash length and dash space applied to the stroke of the text.
See: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray (opens new window) for more information on the SVG stroke-dasharray attribute.
# clone
Two.Path.clone
Returns: Two.Path
Argument | Description |
---|---|
parent | The parent group or scene to add the clone to. |
Create a new instance of Two.Path with the same properties of the current path.
# toObject
Two.Path.toObject
Returns: Object
Return a JSON compatible plain object that represents the path.
# corner
Two.Path.corner
Orient the vertices of the shape to the upper left-hand corner of the path.
# getBoundingClientRect
Two.Path.getBoundingClientRect
Returns: Object
- Returns object with top, left, right, bottom, width, height attributes.
Argument | Description |
---|---|
shallow | Describes whether to calculate off local matrix or world matrix. |
Return an object with top, left, right, bottom, width, and height parameters of the path.
# getPointAt
Two.Path.getPointAt
Returns: Object
Argument | Description |
---|---|
t | Percentage value describing where on the Two.Path to estimate and assign coordinate values. |
obj | Object to apply calculated x, y to. If none available returns new Object . |
Given a float t
from 0 to 1, return a point or assign a passed obj
's coordinates to that percentage on this Two.Path's curve.
# plot
Two.Path.plot
Based on closed / curved and sorting of vertices plot where all points should be and where the respective handles should be too.
# subdivide
Two.Path.subdivide
Argument | Description |
---|---|
limit | How many times to recurse subdivisions. |
Insert a Two.Anchor at the midpoint between every item in Two.Path.vertices.
# clip
Two.Path.clip
Tells Two.js renderer if this object represents a mask for another object (or not).