ThorVG WebCanvas API - v1.1.4
    Preparing search index...

    Class FillAbstract

    Hierarchy (View Summary)

    Index
    _filled: boolean = false
    _stops: ColorStopEntry[] = []
    • get ptr(): number

      Gets the WASM pointer for this object Returns 0 if object has been disposed (error handled by global handler)

      Returns number

    • get isDisposed(): boolean

      Check if this object has been disposed

      Returns boolean

    • Cleanup function to be implemented by subclasses

      Parameters

      • ptr: number

        The WASM pointer to clean up

      Returns void

    • Add a color stop to the gradient

      Parameters

      • offset: number

        Position of the stop (0.0 to 1.0)

      • color: ColorStop

        RGBA color [r, g, b, a] where each value is 0-255

      Returns this

    • Clear all pending color stops Use this to reset stops before adding new ones

      Returns this

      The Fill instance for method chaining

      const gradient = new TVG.LinearGradient(0, 0, 200, 0);
      gradient.addStop(0, [255, 0, 0, 255])
      .addStop(1, [0, 0, 255, 255]);

      // Change stops
      gradient.clearStops()
      .addStop(0, [0, 255, 0, 255])
      .addStop(1, [255, 255, 0, 255]);

      shape.fill(gradient);
    • Replace all color stops with new ones This is a convenience method that clears existing stops and adds new ones in one call

      Parameters

      • ...stops: [number, ColorStop][]

        Variable number of [offset, color] tuples

      Returns this

      The Fill instance for method chaining

      const gradient = new TVG.LinearGradient(0, 0, 200, 0);
      gradient.setStops(
      [0, [255, 0, 0, 255]], // Red at start
      [0.5, [255, 255, 0, 255]], // Yellow at middle
      [1, [0, 255, 0, 255]] // Green at end
      );

      shape.fill(gradient);

      // Later, completely replace stops
      gradient.setStops(
      [0, [0, 0, 255, 255]], // Blue at start
      [1, [255, 0, 255, 255]] // Magenta at end
      );

      shape.fill(gradient); // Re-apply with new stops
    • Apply collected color stops to the gradient ColorStop struct: {float offset, uint8_t r, g, b, a} = 8 bytes per stop

      Returns void