canvas text gradient

Solutions on MaxInterview for canvas text gradient by the best coders in the world

showing results for - "canvas text gradient"
Alejandra
30 May 2018
1var c=document.getElementById("myCanvas");
2var ctx=c.getContext("2d");
3
4ctx.font="20px Georgia";
5ctx.fillText("Hello World!",10,50);
6
7ctx.font="30px Verdana";
8// Create gradient
9var gradient=ctx.createLinearGradient(0,0,c.width,0);
10gradient.addColorStop("0","magenta");
11gradient.addColorStop("0.5","blue");
12gradient.addColorStop("1.0","red");
13// Fill with gradient
14ctx.fillStyle=gradient;
15ctx.fillText("Big smile!",10,90);
16