Copy link to clipboard
Copied
Is there a way to do a gradient on dynamic text with HTML5 canvas in Adobe Animate. I could probably get it to work by manually editing the exported HTML but just wondering if there is a way to do it from with in Animate. I am thinking appending CSS to the dynamic text as a way to do it. Has anyone done this.
1 Correct answer
var txt = this.myText;
var fill = canvas.getContext("2d").createLinearGradient(0, 0, 0, txt.getBounds().height);
fill.addColorStop(0, "#F00");
fill.addColorStop(0.5, "#0F0");
fill.addColorStop(1, "#00F");
txt.color = fill;
CanvasRenderingContext2D.createLinearGradient() - Web APIs | MDN
Copy link to clipboard
Copied
Copy link to clipboard
Copied
var txt = this.myText;
var fill = canvas.getContext("2d").createLinearGradient(0, 0, 0, txt.getBounds().height);
fill.addColorStop(0, "#F00");
fill.addColorStop(0.5, "#0F0");
fill.addColorStop(1, "#00F");
txt.color = fill;
CanvasRenderingContext2D.createLinearGradient() - Web APIs | MDN

