Advertisement
Guest User

Untitled

a guest
Nov 16th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.60 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <meta charset="utf-8">
  5.         <title>Antraste</title>
  6.         <style>
  7.             body {
  8.                 margin: 0px;
  9.             }
  10.         </style>
  11.     </head>
  12.     <body>
  13.         <canvas id="cvs" width="500" height="500"></canvas>
  14.         <script>
  15.             var d = document;
  16.             var c = d.getElementById("cvs");
  17.             var ctx = c.getContext("2d");
  18.             var i = 0;
  19.            
  20.             var Ball = function(x,y, r, sx,sy, color){
  21.                 this.x = x;
  22.                 this.y = y;
  23.                 this.r = r;
  24.                 this.sx = sx;
  25.                 this.sy = sy;
  26.                 this.color = color;
  27.                
  28.                 this.draw = function(){
  29.                     ctx.save();
  30.                     ctx.fillStyle = this.color;
  31.                     ctx.beginPath();
  32.                     ctx.arc(this.x, this.y, this.r, 0, Math.PI*2);
  33.                     ctx.fill();
  34.                     ctx.restore();
  35.                 }
  36.             }
  37.            
  38.             var bumbulis = new Ball(50, 50, 20, 2, 5, "blue");
  39.            
  40.             function frame(){ // Kadras
  41.                 calc();
  42.                 render();
  43.                 requestAnimationFrame(frame);
  44.             }
  45.            
  46.             function calc(){ // Skaiciavimas
  47.                
  48.             }
  49.            
  50.             function render(){ // Piesimas ekrane
  51.                 ctx.clearRect(0,0,c.width,c.height);
  52.                 bumbulis.draw();
  53.             }
  54.            
  55.             frame();
  56.         </script>
  57.     </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement