BetaBeta
The gradient sweeps a full turn clockwise around the center (cx, cy), beginning at angle. Color stop offsets from 0 to 1 map clockwise over one full turn from angle.
The horizontal coordinate of the center of the gradient
The vertical coordinate of the center of the gradient
The initial angle in degrees, measured clockwise from the 3 o'clock direction (positive x-axis). Default: 0
Beta
Gets the WASM pointer for this object Returns 0 if object has been disposed (error handled by global handler)
Beta
Check if this object has been disposed
Beta
Build the gradient (apply all color stops) This should be called after all addStop() calls
Protected_Beta
Cleanup function to be implemented by subclasses
The WASM pointer to clean up
Beta
Add a color stop to the gradient
Position of the stop (0.0 to 1.0)
RGBA color [r, g, b, a] where each value is 0-255
Beta
Clear all pending color stops Use this to reset stops before adding new ones
The Fill instance for method chaining
Beta
Replace all color stops with new ones This is a convenience method that clears existing stops and adds new ones in one call
Variable number of [offset, color] tuples
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
Protected_Beta
Apply collected color stops to the gradient ColorStop struct: {float offset, uint8_t r, g, b, a} = 8 bytes per stop
Beta
Manually dispose of this object and free its WASM memory
Conic gradient for filling shapes
The gradient color transitions by the angle measured around a center point, completing a full clockwise turn from the start angle.
Spread options are ignored because the gradient always sweeps a full turn.
Example
Example