Advertisement
loreng

paste

Nov 17th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.82 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Canvas</title>
  5.         <style type="text/css">
  6.             body,
  7.             html{
  8.                 padding: 0;
  9.                 margin: 0;
  10.             }
  11.  
  12.         </style>
  13.     </head>
  14.     <body>
  15.         <canvas id="canvas" width="550" height="350" style="border:1px solid #000000;"></canvas>
  16.         <script type="text/javascript">
  17.             var canvas = document.getElementById('canvas');
  18.             var context = canvas.getContext('2d');
  19.             var r = 0;
  20.             var x = r;
  21.             var move = 'go_r';
  22.  
  23.             setInterval(function(){
  24.                 context.fillStyle = "#000";
  25.                 context.fillRect(0,0, context.canvas.width, context.canvas.height);
  26.  
  27.                 context.beginPath();
  28.                 context.fillStyle = "red";
  29.                 context.arc(x++,context.canvas.height/2,20,0,2*Math.PI);
  30.                 context.fill();
  31.  
  32.                 if(x >= context.canvas.width - 10){
  33.                     x = 10;
  34.                 }
  35.                
  36.             },10);
  37.         </script>
  38.     </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement