I’m trying to use the canvas 2d radial gradient but I’m not being successful at it, I thought I was doing something wrong but I already tried in the browser the same code and it works in the browser and not in UXP.
I tried with same code using linear gradient and it works, but radial gradient isn’t working.
Here’s the code for the linear gradient:
const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");
// const gradient = ctx.createRadialGradient(150, 150, 0, 150, 150, 100);
const gradient = ctx.createLinearGradient(0, 0, 300, 0);
gradient.addColorStop(0, "blue");
gradient.addColorStop(1, "green");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 300, 300);
Now if I comment the linear gradient and uncomment the radial gradient it doesn’t work, same settings:
const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");
const gradient = ctx.createRadialGradient(150, 150, 0, 150, 150, 100);
// const gradient = ctx.createLinearGradient(0, 0, 300, 0);
gradient.addColorStop(0, "blue");
gradient.addColorStop(1, "green");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 300, 300);
I already tried in the browser and it works but in UXP isn’t working so this must be a but or it is not implemented yet?