A Gradient object representing a linear or radial gradient fill. Created via Renderer#createLinearGradient or Renderer#createRadialGradient. Can be passed to Renderer#setColor as a fill style.
the gradient type
gradient coordinates [x0, y0, x1, y1] for linear, [x0, y0, r0, x1, y1, r1] for radial
Add a color stop to the gradient.
value between 0.0 and 1.0
a CSS color string or Color object
this gradient for chaining
gradient.addColorStop(0, "#FF0000");gradient.addColorStop(0.5, "green");gradient.addColorStop(1, "blue"); Copy
gradient.addColorStop(0, "#FF0000");gradient.addColorStop(0.5, "green");gradient.addColorStop(1, "blue");
Release pooled resources held by this gradient.
Get the interpolated color at a given position along the gradient. Useful for procedural effects like trails that need per-segment colors.
position along the gradient (0.0–1.0)
output Color object to write into
the output Color object
const gradient = new Gradient("linear", [0, 0, 1, 0]);gradient.addColorStop(0, "#ff0000");gradient.addColorStop(1, "#0000ff");gradient.getColorAt(0.5, myColor); // myColor is now purple Copy
const gradient = new Gradient("linear", [0, 0, 1, 0]);gradient.addColorStop(0, "#ff0000");gradient.addColorStop(1, "#0000ff");gradient.getColorAt(0.5, myColor); // myColor is now purple
A Gradient object representing a linear or radial gradient fill. Created via Renderer#createLinearGradient or Renderer#createRadialGradient. Can be passed to Renderer#setColor as a fill style.