VectorPath
ClassAn immutable 2D path: an ordered list of contours built from straight and curved segments.
- Snapchat: not supported
- SPECS: fully supported
- Camera Kit Web: not supported
- Camera Kit Mobile: not supported
- SnapchatNot supported — Available on SPECS only
- SPECSFully supported
- Camera Kit WebNot supported — Available on SPECS only
- Camera Kit MobileNot supported — Available on SPECS only
Since Lens Scripting v370
An immutable 2D path: an ordered list of contours built from straight and curved
segments. Produced by VectorPathBuilder#build and never mutated after.
Exposes read-only geometry — the number of contours and on-path anchor points, the
axis-aligned Rect bounds, and arc lengths. Coordinates are 2-component
vectors [x, y].
Index
Properties
Methods
Example
var builder = VectorPathBuilder.create();
builder.moveTo([0, 0]);
builder.lineTo([1, 0]);
builder.lineTo([1, 1]);
var path = builder.build();
print(path.subpathCount); // 1
print(path.pointCount); // 3
print(path.totalLength); // 2
Extends
Properties
bounds
readonlybounds:Rect
SPECS
The axis-aligned bounding box of the path geometry, as a Rect. Curved segments contribute their flattened extent. An empty path reports a zero rectangle.
Since
Lens Scripting Version 370
isEmpty
readonlyisEmpty:boolean
SPECS
True when the path has no drawable geometry (no segments).
Since
Lens Scripting Version 370
pointCount
readonlypointCount:number
SPECS
The number of on-path anchor points — the endpoints passed to
moveTo/lineTo/cubicTo/quadTo. Control points are not counted. Equals
getPoints().length.
Since
Lens Scripting Version 370
subpathCount
readonlysubpathCount:number
SPECS
The number of contours (subpaths) in the path. Each moveTo on the builder
begins a new contour.
Since
Lens Scripting Version 370
totalLength
readonlytotalLength:number
SPECS
The sum of the arc lengths of all contours. Curved segments are measured by flattening.
Since
Lens Scripting Version 370
Methods
contourLength()
contourLength(
index):number
SPECS
The arc length of contour index (0-based). Throws if index is out of range.
Parameters
| Parameter | Type |
|---|---|
index | number |
Returns
number
Since
Lens Scripting Version 370
getPoints()
getPoints():
vec2[]
SPECS
The on-path anchor points (the segment endpoints), in path order across all contours. Control points are not included.
Returns
vec2[]
Since
Lens Scripting Version 370
getTypeName()
staticgetTypeName():TypeName<VectorPath>
SPECS
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<VectorPath>
Since
Lens Scripting Version 370
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean