Preparing search index...

    Class VectorGradientBuilder

    A mutable builder for an immutable VectorGradient paint. Start one with the VectorGradientBuilder.linear or VectorGradientBuilder.radial factory, add at least two color stops with VectorGradientBuilder#addColorStop, optionally set a focal circle (VectorGradientBuilder#setFocal, radial only) and a spread mode, then call VectorGradientBuilder#build to produce the gradient. Coordinates are native vec2 values in the consuming composite's coordinate space (the same space as path points); colors are normalized straight-alpha vec4 values. The builder remains usable after build().

    Lens Scripting Version 370

    // A linear gradient, reusable across multiple filled paths.
    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 sunset = gb.build();

    // A radial gradient with an off-center focal highlight.
    var rb = VectorGradientBuilder.radial(new vec2(256, 256), 200);
    rb.setFocal(new vec2(210, 210), 0);
    rb.addColorStop(0.0, new vec4(1, 1, 1, 1));
    rb.addColorStop(1.0, new vec4(0, 0, 0, 1));
    var glow = rb.build();

    Hierarchy (View Summary)

    Index

    Methods

    • Adds a color stop at offset (a finite Number, clamped to [0, 1]) with color (a normalized straight-alpha RGBA vec4; components outside [0, 1] are clamped). Stops may be added in any order — VectorGradientBuilder#build sorts them ascending by offset (stably, so equal offsets keep insertion order). Throws if offset or any color component is not finite.

      Parameters

      • offset: number

        The stop position (Number, finite, clamped to [0, 1]).

      • color: vec4

        Normalized RGBA color (vec4, each component clamped to [0, 1]).

      Returns void

      Lens Scripting Version 370

    • Validates the accumulated state and returns a new immutable VectorGradient. Throws if the builder does not have between 2 and 16 color stops. The stops are sorted ascending by offset (stably) in the returned gradient. The builder remains usable afterward; the returned gradient is an independent snapshot.

      Returns VectorGradient

      Lens Scripting Version 370

    • 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 string

      Lens Scripting Version 370

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

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean

    • Creates a builder for a linear gradient whose color ramp runs from start (parameter 0) to end (parameter 1). Throws if start and end coincide, or if either coordinate is not finite.

      Parameters

      • start: vec2

        The gradient's start point (vec2), in composite coordinate space.

      • end: vec2

        The gradient's end point (vec2), in composite coordinate space.

      Returns VectorGradientBuilder

      Lens Scripting Version 370

    • Creates a builder for a radial gradient centered at center with outer radius radius. Without a VectorGradientBuilder#setFocal call the gradient is concentric (focal point at the center, focal radius 0). Throws if radius is not greater than 0, or if center or radius is not finite.

      Parameters

      • center: vec2

        The gradient's center (vec2), in composite coordinate space.

      • radius: number

        The outer radius (Number, must be > 0).

      Returns VectorGradientBuilder

      Lens Scripting Version 370

    • Radial only: sets the focal circle for an off-center highlight. By default (no call) the gradient is concentric. Throws if called on a linear builder, if focalRadius is negative, or if focalCenter or focalRadius is not finite.

      Parameters

      • focalCenter: vec2

        The focal point (vec2), in composite coordinate space.

      • focalRadius: number

        The focal radius (Number, must be >= 0).

      Returns void

      Lens Scripting Version 370

    • Sets the VectorComposite.SpreadMode — how the gradient extends beyond its [0, 1] range. Defaults to VectorComposite.SpreadMode.Pad.

      Parameters

      Returns void

      Lens Scripting Version 370