VectorPathBuilder
ClassA mutable builder for an immutable VectorPath.
- 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
A mutable builder for an immutable VectorPath. Add contours with moveTo
and connect them with straight (lineTo) or curved (cubicTo, quadTo) segments,
then call VectorPathBuilder#build to produce the path. A moveTo finalizes
the current contour and begins a new one. Calling a draw method
(lineTo/cubicTo/quadTo) before any moveTo starts a new contour at that
target point. Coordinates are 2-component vectors [x, y].
Index
Example
var builder = VectorPathBuilder.create();
builder.moveTo([0, 0]);
builder.lineTo([1, 0]);
builder.cubicTo([1, 0.5], [0.5, 1], [0, 1]);
var path = builder.build();
Extends
Methods
build()
build():
VectorPath
SPECS
Captures the accumulated geometry and returns a new immutable VectorPath. The builder remains usable afterward; the returned path is an independent snapshot, so subsequent edits do not affect it.
Returns
Since
Lens Scripting Version 370
create()
staticcreate():VectorPathBuilder
SPECS
Creates a new, empty path builder.
Returns
VectorPathBuilder
Since
Lens Scripting Version 370
cubicTo()
cubicTo(
c1,c2,end):void
SPECS
Adds a cubic Bezier segment from the current point through control points c1
and c2 to end. With no current point, behaves as a moveTo to end.
Parameters
Returns
void
Since
Lens Scripting Version 370
getTypeName()
staticgetTypeName():TypeName<VectorPathBuilder>
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<VectorPathBuilder>
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
Inherited from
lineTo()
lineTo(
pt):void
SPECS
Adds a straight segment from the current point to pt. With no current point,
behaves as a moveTo to pt.
Parameters
| Parameter | Type |
|---|---|
pt | vec2 |
Returns
void
Since
Lens Scripting Version 370
moveTo()
moveTo(
pt):void
SPECS
Finalizes the current contour (if any) and begins a new contour at pt.
Parameters
| Parameter | Type |
|---|---|
pt | vec2 |
Returns
void
Since
Lens Scripting Version 370
quadTo()
quadTo(
c,end):void
SPECS
Adds a quadratic Bezier segment from the current point through control point c
to end. With no current point, behaves as a moveTo to end.
Parameters
Returns
void
Since
Lens Scripting Version 370