Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Canvas</title>
- <style type="text/css">
- body,
- html{
- padding: 0;
- margin: 0;
- }
- </style>
- </head>
- <body>
- <canvas id="canvas" width="550" height="350" style="border:1px solid #000000;"></canvas>
- <script type="text/javascript">
- var canvas = document.getElementById('canvas');
- var context = canvas.getContext('2d');
- var r = 0;
- var x = r;
- var move = 'go_r';
- setInterval(function(){
- context.fillStyle = "#000";
- context.fillRect(0,0, context.canvas.width, context.canvas.height);
- context.beginPath();
- context.fillStyle = "red";
- context.arc(x++,context.canvas.height/2,20,0,2*Math.PI);
- context.fill();
- if(x >= context.canvas.width - 10){
- x = 10;
- }
- },10);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement