-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbola_de_fogo.html
More file actions
71 lines (50 loc) · 1.72 KB
/
bola_de_fogo.html
File metadata and controls
71 lines (50 loc) · 1.72 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var SCREEN_WIDTH = 465;
var SCREEN_HEIGHT = 465;
var SCREEN_CENTER_X = SCREEN_WIDTH/2;
var SCREEN_CENTER_Y = SCREEN_HEIGHT/2;
var Particle = tm.createClass({
superClass: tm.app.CanvasElement,
init: function(x, y) {
this.superInit();
this.position.set(x, y);
this.beginPosition = this.position.clone();
this.velocity = tm.geom.Vector2(
tm.util.Random.randint(-5, 5),
tm.util.Random.randint(-6, 3)
);
this.size = tm.util.Random.randint(35, 45);
this.blendMode = "lighter";
},
update: function() {
this.position.add(this.velocity);
this.velocity.x += (this.beginPosition.x-this.x)/(this.size/2);
this.velocity.y -= 0.4;
this.size -= 1.3;
if (this.size < 1) {
this.remove();
}
else {
var radialGradient = tm.graphics.RadialGradient(0, 0, 0, 0, 0, this.size);
radialGradient.addColorStopList([
{ offset: 0.0, color: "hsla({0}, 75%, 50%, 1.0)".format(tm.util.Random.randint(0, 60)) },
{ offset: 1.0, color: "hsla({0}, 75%, 50%, 0.0)".format(tm.util.Random.randint(0, 60)) },
]);
this.fillStyle = radialGradient.toStyle();
}
},
draw: function(canvas) {
canvas.fillCircle(0, 0, this.size);
}
});
tm.main(function() {
var app = tm.app.CanvasApp("#world");
app.resize(SCREEN_WIDTH, SCREEN_HEIGHT);
app.fitWindow();
app.currentScene.update = function() {
var pointing = app.pointing;
for (var i=0; i<10; ++i) {
Particle(pointing.x, pointing.y).addChildTo(this);
}
};
app.run();
});