-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtextpop.js
More file actions
45 lines (42 loc) · 1.2 KB
/
Copy pathtextpop.js
File metadata and controls
45 lines (42 loc) · 1.2 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
/*==============================================================================
Init
==============================================================================*/
$.TextPop = function( opt ) {
for( var k in opt ) {
this[k] = opt[k];
}
this.alpha = 2;
this.vy = 0;
};
/*==============================================================================
Update
==============================================================================*/
$.TextPop.prototype.update = function( i ) {
this.vy -= 0.05;
this.y += this.vy * $.dt;
this.alpha -= 0.03 * $.dt;
if( this.alpha <= 0 ){
$.textPops.splice( i, 1 );
}
};
/*==============================================================================
Render
==============================================================================*/
$.TextPop.prototype.render = function( i ) {
$.ctxmg.beginPath();
$.text( {
ctx: $.ctxmg,
x: this.x,
y: this.y,
text: '+' + this.value,
hspacing: 1,
vspacing: 0,
halign: 'center',
valign: 'center',
scale: 2,
snap: 0,
render: 1
} );
$.ctxmg.fillStyle = 'hsla(' + this.hue + ', ' + this.saturation + '%, ' + this.lightness + '%, ' + this.alpha + ')';
$.ctxmg.fill();
}