Skip to main content

VectorPathBuilder

Class

A 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

Platform details

  • Snapchat — Not supported — Available on SPECS only.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported — Available on SPECS only.

  • Camera Kit Mobile — Not 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

VectorPath

Since

Lens Scripting Version 370


create()

static create(): 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

ParameterType
c1vec2
c2vec2
endvec2

Returns

void

Since

Lens Scripting Version 370


getTypeName()

static getTypeName(): 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

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


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

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame


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

ParameterType
ptvec2

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

ParameterType
ptvec2

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

ParameterType
cvec2
endvec2

Returns

void

Since

Lens Scripting Version 370