Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var output;
- var canvas;
- var context;
- var width = 640;
- var height = 480;
- var gCells;
- var stepIntervalID;
- var frameRate = 40;
- var stepDuration = 1000/frameRate;
- var time;
- function init () {
- output = document.getElementById("output");
- canvas = document.getElementById("canvas");
- canvas.width = width;
- canvas.height = height;
- context = canvas.getContext("2d");
- time = 0;
- }
- function main () {
- init();
- stepIntervalID = setInterval("step();", stepDuration);
- }
- function step () {
- context.fillStyle = "rgba(0,0,255, 0.5)";
- context.beginPath();
- var x = width/2 + Math.sin(time*0.1)*200;
- var y = height/2 + Math.sin(time*0.15+Math.PI/2)*200;
- context.arc(x,y, 10, 0,7);
- context.fill();
- time += 1;
- }
Add Comment
Please, Sign In to add comment