OLD | NEW |
(Empty) | |
| 1 <canvas id="canvas" width="100" height="100"></canvas> |
| 2 <script> |
| 3 var canvas = document.getElementById('canvas'); |
| 4 var ctx = canvas.getContext('2d'); |
| 5 ctx.fillStyle = '#000'; |
| 6 ctx.arc(50, 50, 25, 0, Math.PI * 2, true); |
| 7 ctx.fill(); |
| 8 var tmp_canvas = canvas.cloneNode(); |
| 9 var tmp_ctx = tmp_canvas.getContext('2d'); |
| 10 tmp_ctx.fillStyle = '#0f0'; |
| 11 tmp_ctx.fillRect(25, 25, 50, 50); |
| 12 tmp_ctx.fillStyle = '#000'; |
| 13 tmp_ctx.fillRect(25, 65, 50, 10); |
| 14 ctx.globalCompositeOperation = 'source-in'; |
| 15 ctx.drawImage(tmp_canvas, 0, 0); |
| 16 </script> |
OLD | NEW |