canvas-drawImage-alpha-1.html (594B)
1 <html> 2 <head> 3 <script type="text/javascript"> 4 function go() { 5 var canvas = document.getElementById("canvas"); 6 var ctx = canvas.getContext("2d"); 7 var image = document.getElementById("image"); 8 9 // Draw some orange 10 ctx.fillStyle = "orange"; 11 ctx.fillRect(0, 0, 100, 100); 12 13 ctx.globalAlpha = 0.25; 14 ctx.drawImage(image, 0, 0); 15 } 16 </script> 17 </head> 18 <body onload="go()"> 19 <canvas id="canvas" width="200" height="200"></canvas> 20 <img id="image" src="lime100x100.svg" style="display: none"> 21 </body> 22 </html>