Skip to main content

VectorStrokeBuilder

Class

A mutable builder for an immutable VectorStroke style.

  • 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 VectorStroke style. Start one with VectorStrokeBuilder.create, optionally refine with VectorStrokeBuilder#setCap, VectorStrokeBuilder#setJoin, VectorStrokeBuilder#setMiterLimit, and VectorStrokeBuilder#setDash, then call VectorStrokeBuilder#build to produce the stroke. The builder remains usable after build().

Index

Example

// A dashed round-capped stroke, reusable across multiple stroked paths.
var sb = VectorStrokeBuilder.create(6);
sb.setCap(VectorComposite.LineCap.Round);
sb.setJoin(VectorComposite.LineJoin.Round);
sb.setDash([24, 12], 0);
var stroke = sb.build();

Extends

Methods

build()

build(): VectorStroke

SPECS

Returns a new immutable VectorStroke that snapshots the current builder state. The builder remains usable afterward; the returned stroke is an independent snapshot.

Returns

VectorStroke

Since

Lens Scripting Version 370


create()

static create(width): VectorStrokeBuilder

SPECS

Creates a builder for a stroke with the given width. Throws if width is not greater than 0, or if width is not finite.

Parameters

ParameterTypeDescription
widthnumberThe stroke width (Number, must be > 0), in composite coordinate space.

Returns

VectorStrokeBuilder

Since

Lens Scripting Version 370


getTypeName()

static getTypeName(): TypeName<VectorStrokeBuilder>

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<VectorStrokeBuilder>

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


setCap()

setCap(cap): void

SPECS

Sets the VectorComposite.LineCap — how the ends of open sub-paths and dash segments are rendered. Defaults to Butt (the SVG default).

Parameters

ParameterTypeDescription
capLineCapThe line cap style.

Returns

void

Since

Lens Scripting Version 370


setDash()

setDash(pattern, offset): void

SPECS

Sets an optional dash pattern. pattern is an array of finite, non-negative Numbers defining alternating on/off segment lengths; an empty array (the default) means a continuous stroke. offset is a finite phase offset into the pattern. An odd-length pattern is valid — ThorVG/SVG repeat it to an even length internally. Throws if any pattern entry is negative or not finite, or if offset is not finite.

Parameters

ParameterTypeDescription
patternnumber[]An array of alternating on/off lengths (each >= 0, finite); empty = no dashing.
offsetnumberPhase offset into the pattern (Number, finite).

Returns

void

Since

Lens Scripting Version 370


setJoin()

setJoin(join): void

SPECS

Sets the VectorComposite.LineJoin — how corners between connected path segments are rendered. Defaults to Miter (the SVG default).

Parameters

ParameterTypeDescription
joinLineJoinThe line join style.

Returns

void

Since

Lens Scripting Version 370


setMiterLimit()

setMiterLimit(limit): void

SPECS

Sets the miter limit — the ratio at which a Miter join falls back to a bevel. Must be finite and >= 1. Defaults to 4 (the SVG default). Throws if limit is less than 1, or if limit is not finite.

Parameters

ParameterTypeDescription
limitnumberThe miter limit (Number, must be >= 1).

Returns

void

Since

Lens Scripting Version 370