Skip to main content

VectorGradient

Class

An immutable gradient paint — a linear or radial color ramp with a VectorComposite.SpreadMode.

  • 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 gradient paint — a linear or radial color ramp with a VectorComposite.SpreadMode. Produced by VectorGradientBuilder#build and never mutated after. A gradient carries only paint (geometry + color stops + spread), not path geometry, so it is freely shareable: wrap it in a VectorPaint.gradient and pass that paint to multiple VectorCompositeBuilder#addPath calls to fill several paths with one gradient. Exposes read-only metadata — its VectorGradient#kind, VectorGradient#stopCount, and VectorGradient#spread.

Index

Example

var gb = VectorGradientBuilder.linear(new vec2(0, 0), new vec2(512, 0));
gb.addColorStop(0.0, new vec4(0.92, 0.26, 0.21, 1.0));
gb.addColorStop(1.0, new vec4(0.13, 0.59, 0.95, 1.0));
gb.setSpread(VectorComposite.SpreadMode.Reflect);
var gradient = gb.build();
print(gradient.kind); // VectorComposite.GradientKind.Linear
print(gradient.stopCount); // 2

Extends

Properties

kind

readonly kind: GradientKind

SPECS

Whether this gradient is linear or radial.

Since

Lens Scripting Version 370


spread

readonly spread: SpreadMode

SPECS

The VectorComposite.SpreadMode — how the gradient extends beyond its [0, 1] parameter range.

Since

Lens Scripting Version 370


stopCount

readonly stopCount: number

SPECS

The number of color stops (between 2 and 16, inclusive).

Since

Lens Scripting Version 370

Methods

getTypeName()

static getTypeName(): TypeName<VectorGradient>

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

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