Advertisement
Guest User

Untitled

a guest
May 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <!--
  3. To change this license header, choose License Headers in Project Properties.
  4. To change this template file, choose Tools | Templates
  5. and open the template in the editor.
  6. -->
  7. <html>
  8.     <head>
  9.         <title>TODO supply a title</title>
  10.         <meta charset="UTF-8">
  11.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  12.         <style>
  13.             canvas {
  14.                 position: fixed; left: 10px; top: 10px;
  15.             }
  16.         </style>
  17.         <script>        
  18.             var canvas;
  19.             var ctx;
  20.             function init()
  21.             {
  22.                 canvas=document.getElementById("canvas");
  23.                 ctx=canvas.getContext("2d");
  24.                 animacja();
  25.             }
  26.             function animacja()
  27.             {
  28.                 y=100;
  29.                 x=100;
  30.                 requestAnimationFrame(animacja);
  31.                 ctx.clearRect(0,0,innerWidth,900);
  32.                 ctx.beginPath();
  33.                 ctx.arc(x,y,15,0,2*Math.PI);
  34.                 ctx.stroke();
  35.                 ctx.fillStyle = "#cccccc";
  36.                 ctx.fill();
  37.                
  38.                 if (x + 1300>innerWidth || x<0)
  39.                 {
  40.                     x=x+1;
  41.                 }
  42.             }
  43.         </script>
  44.     </head>
  45.     <body onload="init()">
  46.         <canvas id="canvas" width="1280" height="720"></canvas>
  47.     </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement