paint2d-reset-ref.html (458B)
1 <!DOCTYPE html> 2 <html> 3 <body> 4 <canvas id="output" width="100" height="100"></canvas> 5 <script> 6 var canvas = document.getElementById('output'); 7 var ctx = canvas.getContext('2d'); 8 9 ctx.fillStyle = 'yellow'; 10 ctx.fillRect(10, 10, 50, 50); 11 ctx.fillStyle = 'magenta'; 12 ctx.fillRect(20, 20, 50, 50); 13 ctx.strokeStyle = 'cyan'; 14 ctx.moveTo(40, 0); 15 ctx.reset(); 16 ctx.lineWidth = 10; 17 ctx.lineTo(0, 40); 18 ctx.stroke(); 19 ctx.fillRect(30, 30, 20, 20); 20 </script> 21 </body> 22 </html>