OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <canvas width=100 height=100></canvas> | 2 <canvas width=100 height=100></canvas> |
3 <script> | 3 <script> |
4 var img = new Image(); | 4 var img = new Image(); |
| 5 img.onload = imgOnLoad; |
5 img.src = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><rect widt
h="100" height="100" fill="#008000"/></svg>'; | 6 img.src = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><rect widt
h="100" height="100" fill="#008000"/></svg>'; |
6 var c = document.querySelector('canvas').getContext('2d'); | 7 function imgOnLoad() { |
7 c.globalAlpha = 0.5; | 8 var c = document.querySelector('canvas').getContext('2d'); |
8 c.drawImage(img, 0, 0); | 9 c.globalAlpha = 0.5; |
| 10 c.drawImage(img, 0, 0); |
| 11 } |
9 </script> | 12 </script> |
OLD | NEW |