Prev Demo
ASP.NET MVC
>
Create A New ASP.NET MVC Application
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>ClearCanvas</title> </head> <body> <style> body { margin: 50px; padding: 0px; } #buttons { position: fixed; top: 15px; left: 10px; } </style> </head> <body> <canvas id="myCanvas" width="600" height="300"></canvas> <div id="buttons"> <input type="button" id="clear" value="Clear"> </div> <script> var canvas = document.getElementById('myCanvas'); var context = canvas.getContext('2d'); context.beginPath(); context.rect(18, 50, 200, 100); context.fillStyle = "red"; context.fill(); context.lineWidth = "20"; context.strokeStyle = "pink"; context.stroke(); document.getElementById('clear').addEventListener('click', function () { context.clearRect(0, 0, canvas.width, canvas.height); }, false); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output