Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <style>
- body {
- margin: 0px;
- padding: 0px;
- }
- </style>
- </head>
- <body onkeypress="MyDraw()">
- <button onclick="MyDraw()">Click Me</button><br>
- <canvas id="myCanvas" width="578" height="200"></canvas>
- <script>
- var canvas = document.getElementById('myCanvas');
- var context = canvas.getContext('2d');
- var x = 100;
- function MyDraw(){
- x+=10;
- context.beginPath();
- context.moveTo(x, 150);
- context.lineTo(450, 50);
- context.stroke();
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement