Support linearGradient/radialGradient when using fillStyle
Author: HolybasilCreated Feb 24, 2025Updated Oct 1, 2025
Currently, we can only pass solid colors, but it would be great to have the ability to apply gradient colors directly to paths when transforming them on the canvas.
const gradient = ctx.createLinearGradient(x1, y1, x2, y2);
gradient.addColorStop(0, 'red');
gradient.addColorStop(1, 'blue');
ctx.fillStyle = gradient;
At present, https://github.com/catdad/canvas-confetti/issues/80#issuecomment-2511208926 works for me.
Source: catdad/canvas-confetti