1304353-text-global-alpha-1.html (749B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 6 <script> 7 function do_test() { 8 var canvas = document.getElementById("test"); 9 var ctx = canvas.getContext("2d"); 10 11 var g = ctx.createLinearGradient(0, 0, canvas.width, canvas.height); 12 g.addColorStop(0, "red"); 13 g.addColorStop(1, "green"); 14 15 ctx.fillStyle = g; 16 ctx.fillRect(0, 0, canvas.width, canvas.height); 17 18 ctx.fillStyle = "white"; 19 ctx.font = "bold 24px sans-serif"; 20 21 ctx.fillText('globalAlpha = 1.0', 20, 40); 22 23 ctx.globalAlpha = 0.5; 24 ctx.fillText('globalAlpha = 0.5', 20, 80); 25 26 ctx.globalAlpha = 0.2; 27 ctx.fillText('globalAlpha = 0.2', 20, 120); 28 }; 29 </script> 30 31 </head> 32 33 <body onload="do_test()"> 34 35 <canvas id="test"></canvas> 36 37 </body> 38 </html>