Skip to content

Commit 64fcb67

Browse files
author
Andrew Mahon (Type/Code)
committed
some small changes to particle code
1 parent a787c91 commit 64fcb67

File tree

2 files changed

+29
-34
lines changed

2 files changed

+29
-34
lines changed

lib/particle/tc.particle.context.js

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,28 @@ if(!tc){ var tc = {}; }
2929
(function(tc) {
3030

3131

32-
(function() {
33-
var lastTime = 0;
34-
var vendors = ['ms', 'moz', 'webkit', 'o'];
35-
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
36-
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
37-
window.cancelAnimationFrame =
38-
window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
39-
}
40-
41-
if (!window.requestAnimationFrame)
42-
window.requestAnimationFrame = function(callback, element) {
43-
var currTime = new Date().getTime();
44-
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
45-
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
46-
timeToCall);
47-
lastTime = currTime + timeToCall;
48-
return id;
49-
};
50-
51-
if (!window.cancelAnimationFrame)
52-
window.cancelAnimationFrame = function(id) {
53-
clearTimeout(id);
54-
};
32+
(function requestAnimationFrame() {
33+
var lastTime = 0;
34+
var vendors = ['ms', 'moz', 'webkit', 'o'];
35+
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
36+
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
37+
window.cancelAnimationFrame =
38+
window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
39+
}
40+
41+
if(!window.requestAnimationFrame)
42+
window.requestAnimationFrame = function(callback, element) {
43+
var currTime = new Date().getTime();
44+
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
45+
var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
46+
lastTime = currTime + timeToCall;
47+
return id;
48+
};
49+
50+
if(!window.cancelAnimationFrame)
51+
window.cancelAnimationFrame = function(id) {
52+
clearTimeout(id);
53+
};
5554
}());
5655

5756
if(!tc.particle){ tc.particle = {}; }
@@ -77,7 +76,6 @@ if(!tc){ var tc = {}; }
7776
_me.particles = [];
7877
_me.frame = 0;
7978
_me.stopped = true;
80-
_me.paused = false;
8179
_me.timer = null;
8280
_me.mouse_pos = null;
8381
_me.mouse_down_pos = null;
@@ -153,12 +151,7 @@ if(!tc){ var tc = {}; }
153151

154152
}
155153

156-
_me.isPaused = function(){
157-
return _paused;
158-
}
159-
160154
_me.start = function(){
161-
_me.paused = false;
162155
_me.mouse_pos = null;
163156
_me.mouse_down_pos = null;
164157
if(_me.stopped){
@@ -167,15 +160,11 @@ if(!tc){ var tc = {}; }
167160
}
168161
}
169162

170-
_me.pause = function(){
171-
_me.paused = true;
172-
}
173-
174163
_me.stop = function(){
175164
_me.stopped = true;
176165
}
177166

178-
function _draw(){
167+
function _draw(drawing_context){
179168
var opacity, i, alpha;
180169

181170
_me.context.globalAlpha = 1.0;
@@ -205,10 +194,15 @@ if(!tc){ var tc = {}; }
205194

206195
_me.context.globalAlpha = alpha;
207196

197+
_me.context.fillStyle = '#000000';
208198
for(i = 0; i < _me.particles.length; i++){
209199
_me.particles[i].draw(_me.context);
210200
}
211201
}
202+
203+
function _render(){
204+
205+
}
212206

213207
return this.initialize();
214208
}

lib/particle/tc.particle.particle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ if(!tc){ var tc = {}; }
7474
(0+o.anchor.y+o.anchor_offset.y)
7575
]);
7676
_me.radius = o.radius;
77+
_me.diameter = o.radius*2;
7778
if(_me.options.opacity < 1.0){
7879
_me.fill = "rgba("+color.getRGBFromHex('r',o.color)+","+color.getRGBFromHex('g',o.color)+","+color.getRGBFromHex('b',o.color)+","+o.opacity+")";
7980
} else {

0 commit comments

Comments
 (0)