forked from shwang/VectorFieldsStudy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParticle.as
33 lines (27 loc) · 863 Bytes
/
Particle.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package {
import flash.display.*;
public class Particle extends WstPoint implements IUpdateable, IDrawable{
public function Particle(x:Number, y:Number) {
super(x, y);
}
public function update():void {
if (Registry.isOffscreen(this)) {
var loc:WstPoint = WstPoint.rand(Registry.DEFAULT_RANGE);
this.x = loc.x;
this.y = loc.y;
}
addTo(Registry.evaluateVectorAt(this));
}
public function draw(g:Graphics):void {
var color:Number = Registry.evaluateColorAt(this);
var prime:WstPoint = Registry.adjustToScreen(this);
g.beginFill(color);
g.drawCircle(prime.x, prime.y, Registry.DEFAULT_RADIUS);
g.endFill();
}
public static function rand(magnitude:Number, origin:WstPoint = null):Particle {
var loc:WstPoint = WstPoint.rand(magnitude, origin);
return new Particle(loc.x, loc.y);
}
}
}