Skip to main content

VectorPath

Class

An 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

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

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

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

readonly bounds: 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

readonly isEmpty: boolean

SPECS

True when the path has no drawable geometry (no segments).

Since

Lens Scripting Version 370


pointCount

readonly pointCount: 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

readonly subpathCount: 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

readonly totalLength: 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

ParameterType
indexnumber

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()

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

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