git @ Cat's Eye Technologies HTML5-Gewgaws / 84b359b
Use requestAnimationFrame (naively) instead of setInterval. Cat's Eye Technologies 11 years ago
9 changed file(s) with 62 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
106106 NonRandomWalk = function() {
107107 var canvas;
108108 var ctx;
109 var intervalId;
109 var request;
110110
111111 var manager;
112112
196196
197197 this.reset();
198198
199 intervalId = setInterval(function() { self.draw(); }, 33);
199 var $this = this;
200 var animFrame = function(time) {
201 $this.draw();
202 request = requestAnimationFrame(animFrame);
203 };
204 request = requestAnimationFrame(animFrame);
200205 };
201206 }
6666 };
6767
6868 Cyclobots = function() {
69 var interval_id = undefined;
69 var request = undefined;
7070 var ctx = undefined;
7171 var canvas = undefined;
7272 var selected = undefined;
152152 e.preventDefault();
153153 });
154154
155 interval_id = setInterval(this.draw, 25);
155 var $this = this;
156 var animFrame = function(time) {
157 $this.draw();
158 request = requestAnimationFrame(animFrame);
159 };
160 request = requestAnimationFrame(animFrame);
156161 };
157162
158163 this.selectABot = function(can_x, can_y) {
4646 };
4747
4848 Fingerspelling = function() {
49 var intervalId;
49 var request;
5050 var options;
5151
5252 var canvas;
153153 e.preventDefault();
154154 });
155155
156 var self = this;
157 intervalId = setInterval(self.draw, 20);
156 var $this = this;
157 var animFrame = function(time) {
158 $this.draw();
159 request = requestAnimationFrame(animFrame);
160 };
161 request = requestAnimationFrame(animFrame);
158162 };
159163 };
8484
8585 HeronsisHermnonicii = function() {
8686 var ctx;
87 var intervalId;
87 var request;
8888
8989 var manager;
9090 var landscape = [];
126126 this.init = function(c) {
127127 canvas = c;
128128 ctx = canvas.getContext('2d');
129 var self = this;
130129
131130 manager = new yoob.SpriteManager();
132131 manager.init(canvas);
151150 treescape[i] = canvas.height * 0.75 + (Math.random() * 60 - 30);
152151 }
153152
154 intervalId = setInterval(function() { self.draw(); }, 33);
153 var $this = this;
154 var animFrame = function(time) {
155 $this.draw();
156 request = requestAnimationFrame(animFrame);
157 };
158 request = requestAnimationFrame(animFrame);
155159 };
156160 }
00 HirsuteMiasma = function() {
11 var canvas;
22 var ctx;
3 var intervalId;
3 var request;
44
55 var x;
66 var y;
7474 canvas = c;
7575 ctx = canvas.getContext('2d');
7676 this.draw();
77 intervalId = setInterval(this.draw, 50);
77 var $this = this;
78 var animFrame = function(time) {
79 $this.draw();
80 request = requestAnimationFrame(animFrame);
81 };
82 request = requestAnimationFrame(animFrame);
7883 }
7984 }
7777 var overlayCanvas;
7878 var ctx;
7979 var overlayCtx;
80 var intervalId;
80 var request;
8181
8282 var manager = new yoob.SpriteManager();
8383
9797 manager.init(canvas);
9898 ctx = canvas.getContext('2d');
9999 overlayCtx = overlayCanvas.getContext('2d');
100 var self = this;
101100
102101 var outside = new Rectangle();
103102 outside.init(0, 0, 0, 0, canvas.width, canvas.height, '', undefined, null);
115114 yellowRectangle.scrawlOn = overlayCtx;
116115 manager.addSprite(yellowRectangle);
117116
118 intervalId = setInterval(function() { self.draw(); }, 16);
117 var $this = this;
118 var animFrame = function(time) {
119 $this.draw();
120 request = requestAnimationFrame(animFrame);
121 };
122 request = requestAnimationFrame(animFrame);
119123 };
120124 }
00 Multicolouralism = function() {
11 var canvas;
22 var ctx;
3 var intervalId;
3 var request;
44 var rows;
55 var cols;
66 var radius;
7373
7474 var animFrame = function(time) {
7575 $this.draw();
76 requestAnimationFrame(animFrame);
76 request = requestAnimationFrame(animFrame);
7777 };
7878
79 requestAnimationFrame(animFrame);
79 request = requestAnimationFrame(animFrame);
8080 };
8181 }
00 PrairieController = function() {
11 var canvas;
2 var interval_id;
2 var request;
33
44 var img = new Image();
55 var shapes = new Array();
4242 shapes[i] = {};
4343 new_shape(i);
4444 }
45 var self = this;
45 var $this = this;
4646 img.onload = function() {
47 self.draw();
48 interval_id = setInterval(self.draw, 20);
47 $this.draw();
48 var animFrame = function(time) {
49 $this.draw();
50 request = requestAnimationFrame(animFrame);
51 };
52 request = requestAnimationFrame(animFrame);
4953 }
5054 img.src = imgurl;
5155 }
5256
5357 this.stop = function() {
54 if (interval_id === undefined)
58 if (request === undefined)
5559 return;
56 clearInterval(interval_id);
57 interval_id = undefined;
60 cancelRequestAnimationFrame(request);
61 request = undefined;
5862 }
5963 }
00 function ProgressionController(canvas) {
11 var self = {};
22 var counter;
3 var interval_id;
3 var request;
44
55 self.draw = function() {
66 var ctx = canvas.getContext('2d');
2828 self.start = function() {
2929 counter = 1;
3030 self.draw();
31 interval_id = setInterval(self.draw, 50);
31 var animFrame = function(time) {
32 self.draw();
33 request = requestAnimationFrame(animFrame);
34 };
35 request = requestAnimationFrame(animFrame);
3236 };
3337
3438 return self;