Skip to main content

VectorPaint

Class

An immutable fill paint for VectorCompositeBuilder#addPath — either a flat solid color or a VectorGradient.

  • 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 fill paint for VectorCompositeBuilder#addPath — either a flat solid color or a VectorGradient. Create one with VectorPaint.solid or VectorPaint.gradient. A VectorPaint carries only paint (color or gradient), not path geometry, so it is freely reusable: pass the same VectorPaint to multiple VectorCompositeBuilder#addPath calls to fill several paths with one paint.

Index

Example

var builder = VectorCompositeBuilder.create(256, 256);

// A solid red paint.
var red = VectorPaint.solid(new vec4(0.92, 0.26, 0.21, 1.0));

// A gradient paint, built from a VectorGradient.
var gb = VectorGradientBuilder.linear(new vec2(0, 0), new vec2(256, 0));
gb.addColorStop(0.0, new vec4(0.13, 0.59, 0.95, 1.0));
gb.addColorStop(1.0, new vec4(0.30, 0.69, 0.31, 1.0));
var sky = VectorPaint.gradient(gb.build());

builder.addPath(trianglePath, red, VectorComposite.FillRule.NonZero);
builder.addPath(skyPath, sky, VectorComposite.FillRule.NonZero);

Extends

Methods

getTypeName()

static getTypeName(): TypeName<VectorPaint>

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

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


gradient()

static gradient(gradient): VectorPaint

SPECS

Creates a gradient paint from an immutable VectorGradient (build one with VectorGradientBuilder). The gradient is referenced as-is — a single VectorGradient may back many paints. Throws if gradient is null.

Parameters

ParameterTypeDescription
gradientVectorGradientThe gradient to paint with.

Returns

VectorPaint

Since

Lens Scripting Version 370


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


solid()

static solid(color): VectorPaint

SPECS

Creates a solid-color paint. color is a normalized RGBA 4-component vector [r, g, b, a] with each component in [0, 1] (components outside this range are clamped).

Parameters

ParameterTypeDescription
colorvec4Normalized RGBA color (each component clamped to [0, 1]).

Returns

VectorPaint

Since

Lens Scripting Version 370