Guest User

Untitled

a guest
Nov 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var output;
  2. var canvas;
  3. var context;
  4.  
  5. var width = 640;
  6. var height = 480;
  7.  
  8. var gCells;
  9.  
  10. var stepIntervalID;
  11. var frameRate = 40;
  12. var stepDuration = 1000/frameRate;
  13. var time;
  14.  
  15. function init () {
  16.     output = document.getElementById("output");
  17.     canvas = document.getElementById("canvas");
  18.     canvas.width = width;
  19.     canvas.height = height;
  20.     context = canvas.getContext("2d");
  21.    
  22.     time = 0;
  23. }
  24.  
  25.  
  26. function main () {
  27.     init();
  28.  
  29.     stepIntervalID = setInterval("step();", stepDuration);
  30. }
  31.  
  32. function step () {
  33.     context.fillStyle = "rgba(0,0,255, 0.5)";
  34.     context.beginPath();
  35.     var x = width/2 + Math.sin(time*0.1)*200;
  36.     var y = height/2 + Math.sin(time*0.15+Math.PI/2)*200;
  37.     context.arc(x,y, 10, 0,7);
  38.     context.fill();
  39.    
  40.     time += 1;
  41. }
Add Comment
Please, Sign In to add comment