Mercurial > MadButterfly
annotate nodejs/animate.js @ 894:460b2629be30
Commit the change again
author | wycc |
---|---|
date | Mon, 27 Sep 2010 23:02:45 +0800 |
parents | cad38ddb1253 |
children | 3136db0ac01b |
rev | line source |
---|---|
794 | 1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
808
diff
changeset
|
2 // vim: sw=4:ts=8:sts=4 |
727 | 3 var sys=require("sys"); |
4 | |
795
46a4cd4d382b
Remove dependent on system time to gain frame rate
Thinker K.F. Li <thinker@codemud.net>
parents:
794
diff
changeset
|
5 /* |
46a4cd4d382b
Remove dependent on system time to gain frame rate
Thinker K.F. Li <thinker@codemud.net>
parents:
794
diff
changeset
|
6 * This is configuration for animate module. For slower or speeder |
46a4cd4d382b
Remove dependent on system time to gain frame rate
Thinker K.F. Li <thinker@codemud.net>
parents:
794
diff
changeset
|
7 * machines, ffs can be decreased or increased respective. |
46a4cd4d382b
Remove dependent on system time to gain frame rate
Thinker K.F. Li <thinker@codemud.net>
parents:
794
diff
changeset
|
8 */ |
844 | 9 var ffs = 12; |
795
46a4cd4d382b
Remove dependent on system time to gain frame rate
Thinker K.F. Li <thinker@codemud.net>
parents:
794
diff
changeset
|
10 var frame_interval = 1000 / ffs; |
46a4cd4d382b
Remove dependent on system time to gain frame rate
Thinker K.F. Li <thinker@codemud.net>
parents:
794
diff
changeset
|
11 |
894 | 12 function shift_draw(percent) { |
795
46a4cd4d382b
Remove dependent on system time to gain frame rate
Thinker K.F. Li <thinker@codemud.net>
parents:
794
diff
changeset
|
13 var percent; |
844 | 14 this.obj.x = (this.targetx-this.startposx)*percent+this.startposx; |
15 this.obj.y = (this.targety-this.startposy)*percent+this.startposy; | |
795
46a4cd4d382b
Remove dependent on system time to gain frame rate
Thinker K.F. Li <thinker@codemud.net>
parents:
794
diff
changeset
|
16 this.app.refresh(); |
727 | 17 } |
795
46a4cd4d382b
Remove dependent on system time to gain frame rate
Thinker K.F. Li <thinker@codemud.net>
parents:
794
diff
changeset
|
18 |
894 | 19 function shift(app,obj,shiftx,shifty) { |
20 obj.animated_shift = this; | |
794 | 21 this.app = app; |
22 this.obj = obj; | |
23 this.end = 0; | |
844 | 24 this.targetx = shiftx + obj.x; |
25 this.targety = shifty + obj.y; | |
26 this.startposx = obj.x; | |
27 this.startposy = obj.y; | |
727 | 28 } |
29 | |
894 | 30 exports.shift = shift; |
31 shift.prototype.draw = shift_draw; | |
758
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
32 |
798
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
33 /* ------------------------------------------------------------ */ |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
34 function rotate(app, obj, ang, duration) { |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
35 this._app = app; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
36 this._obj = obj; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
37 this._ang = ang; |
894 | 38 this._start_mtx = [obj[0], obj[1], obj[2], obj[3], obj[4], obj[5]]; |
798
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
39 } |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
40 |
894 | 41 function rotate_draw(percent) { |
798
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
42 var percent; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
43 var ang; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
44 var sv, cv; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
45 var obj = this._obj; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
46 var mtx, shift; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
47 |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
48 |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
49 ang = percent * this._ang; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
50 sv = Math.sin(ang); |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
51 cv = Math.cos(ang); |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
52 mtx = [cv, -sv, 0, sv, cv, 0]; |
894 | 53 sys.puts('x='+obj.center.x+',y='+obj.center.y); |
808
9b6c26cf9102
Move bounding box and center back to an object
Thinker K.F. Li <thinker@codemud.net>
parents:
806
diff
changeset
|
54 shift = [1, 0, -obj.center.x, 0, 1, -obj.center.y]; |
798
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
55 mtx = multiply(mtx, shift); |
808
9b6c26cf9102
Move bounding box and center back to an object
Thinker K.F. Li <thinker@codemud.net>
parents:
806
diff
changeset
|
56 shift = [1, 0, obj.center.x, 0, 1, obj.center.y]; |
798
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
57 mtx = multiply(shift, mtx); |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
58 mtx = multiply(mtx, this._start_mtx); |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
59 |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
60 obj[0] = mtx[0]; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
61 obj[1] = mtx[1]; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
62 obj[2] = mtx[2]; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
63 obj[3] = mtx[3]; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
64 obj[4] = mtx[4]; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
65 obj[5] = mtx[5]; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
66 |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
67 this._app.refresh(); |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
68 } |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
69 |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
70 rotate.prototype.draw = rotate_draw; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
71 exports.rotate = rotate; |
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
72 |
758
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
73 function multiply(s,d) { |
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
74 var m=[]; |
794 | 75 m[0] = s[0]*d[0]+s[1]*d[3]; |
76 m[1] = s[0]*d[1]+s[1]*d[4]; | |
77 m[2] = s[0]*d[2]+s[1]*d[5]+s[2]; | |
78 m[3] = s[3]*d[0]+s[4]*d[3]; | |
79 m[4] = s[3]*d[1]+s[4]*d[4]; | |
80 m[5] = s[3]*d[2]+s[4]*d[5]+s[5]; | |
798
210e4d24a3ba
Change linear to relative location shifting and add rotate
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
81 return m; |
758
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
82 } |
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
83 |
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
84 |
894 | 85 function scale_draw(percent) { |
758
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
86 if (this.end == 1) return; |
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
87 var sx = (this.targetx-this.startsx)*percent+this.startsx; |
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
88 var sy = (this.targety-this.startsy)*percent+this.startsy; |
794 | 89 var t=[sx,0,0,0,sy,0]; |
90 this.obj[0] = sx; | |
91 this.obj[4] = sy; | |
92 this.obj[2] = this.origin_offset_x - (sx-this.startsx)*this.obj.center.x; | |
93 this.obj[5] = this.origin_offset_y - (sy-this.startsy)*this.obj.center.y; | |
894 | 94 sys.puts('x='+this.obj.center.x+',y='+this.obj.center.y); |
758
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
95 |
794 | 96 this.app.refresh(); |
97 var self = this; | |
98 this.app.refresh(); | |
99 this.obj.animated_scale = null; | |
758
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
100 } |
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
101 |
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
102 function scale(app,obj,targetx,targety, duration) { |
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
103 try { |
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
104 if (obj.animated_scale) { |
794 | 105 //obj[0] = obj.animated_scale.targetx; |
106 //obj[4] = obj.animated_scale.targety; | |
107 //obj[2] = obj.animated_scale.final_offset_x; | |
108 //obj[5] = obj.aninated_scale.final_offset_y; | |
109 obj.animated_scale.end = 1; | |
758
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
110 } |
794 | 111 } catch(e) { |
112 | |
113 } | |
114 obj.animated_scale = this; | |
115 this.app = app; | |
116 this.obj = obj; | |
117 this.end = 0; | |
118 this.starttime = Date.now(); | |
119 this.startsx = obj[0]; | |
120 this.startsy = obj[4]; | |
758
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
121 this.targetx = targetx; |
794 | 122 this.targety = targety; |
123 this.duration = duration*1000; | |
124 this.origin_offset_x = obj[2]; | |
125 this.origin_offset_y = obj[5]; | |
126 this.final_offset_x = this.origin_offset_x-(targetx-this.startsx)*obj.center.x; | |
127 this.final_offset_y = this.origin_offset_y-(targety-this.startsy)*obj.center.y; | |
758
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
128 } |
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
129 |
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
130 |
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
131 exports.scale = scale; |
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
728
diff
changeset
|
132 scale.prototype.draw = scale_draw; |
788
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
133 |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
134 function holder(app, coord) { |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
135 var mtx = [coord[0], coord[1], coord[2], coord[3], coord[4], coord[5]]; |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
136 |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
137 this._mtx = mtx; |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
138 this._coord = coord; |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
139 this._app = app; |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
140 } |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
141 |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
142 holder.prototype = { |
808
9b6c26cf9102
Move bounding box and center back to an object
Thinker K.F. Li <thinker@codemud.net>
parents:
806
diff
changeset
|
143 go: function(pos) { |
788
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
144 var sx, sy; |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
145 |
808
9b6c26cf9102
Move bounding box and center back to an object
Thinker K.F. Li <thinker@codemud.net>
parents:
806
diff
changeset
|
146 sx = pos.x - this._coord.center.x; |
9b6c26cf9102
Move bounding box and center back to an object
Thinker K.F. Li <thinker@codemud.net>
parents:
806
diff
changeset
|
147 sy = pos.y - this._coord.center.y; |
788
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
148 this.shift(sx, sy); |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
149 }, |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
150 |
808
9b6c26cf9102
Move bounding box and center back to an object
Thinker K.F. Li <thinker@codemud.net>
parents:
806
diff
changeset
|
151 go_center: function(o) { |
9b6c26cf9102
Move bounding box and center back to an object
Thinker K.F. Li <thinker@codemud.net>
parents:
806
diff
changeset
|
152 this.go(o.center); |
9b6c26cf9102
Move bounding box and center back to an object
Thinker K.F. Li <thinker@codemud.net>
parents:
806
diff
changeset
|
153 }, |
9b6c26cf9102
Move bounding box and center back to an object
Thinker K.F. Li <thinker@codemud.net>
parents:
806
diff
changeset
|
154 |
788
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
155 home: function() { |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
156 this._coord[2] = this._mtx[2]; |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
157 this._coord[5] = this._mtx[5]; |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
158 this._app.refresh(); |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
159 }, |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
160 |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
161 shift: function(sx, sy) { |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
162 this._coord[2] = this._mtx[2] + sx; |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
163 this._coord[5] = this._mtx[5] + sy; |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
164 this._app.refresh(); |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
165 } |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
166 }; |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
167 |
7ec13634c97d
Add holder for animate
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
168 exports.holder = holder; |
831 | 169 |
170 | |
171 | |
894 | 172 function alpha_draw(percent) { |
831 | 173 |
174 if (this.end == 1) return; | |
175 var sx = (this.targetalpha-this.startalpha)*percent+this.startalpha; | |
176 this.obj.opacity=sx; | |
177 this.app.refresh(); | |
178 this.obj.animated_alpha = null; | |
179 } | |
180 | |
181 function alpha(app,obj,alpha, duration) { | |
182 try { | |
183 if (obj.animated_alpha) { | |
184 obj.animated_alpha.end = 1; | |
185 } | |
186 } catch(e) { | |
187 | |
188 } | |
189 obj.animated_alpha = this; | |
190 this.app = app; | |
191 this.obj = obj; | |
192 this.end = 0; | |
193 this.starttime = Date.now(); | |
194 this.startalpha = obj.opacity; | |
195 this.targetalpha = alpha; | |
196 this.duration = duration*1000; | |
197 } | |
198 | |
199 alpha.prototype.draw = alpha_draw; | |
200 exports.alpha = alpha; | |
894 | 201 |
202 function linear_update() | |
203 { | |
204 var now = Date.now(); | |
205 sys.puts("real time is "+now); | |
206 sys.puts("end is "+this.end); | |
207 if (now >= this.end) { | |
208 this.timer.stop(); | |
209 now = this.end; | |
210 } | |
211 if (now < this.startmove) return; | |
212 sys.puts("now is "+now+" offset is "+(now-this.startmove)); | |
213 var per = (now-this.startmove)/this.duration/1000; | |
214 if (per > 1) per = 1; | |
215 this.action.draw(per); | |
216 } | |
217 | |
218 function linear_start() | |
219 { | |
220 var self = this; | |
221 if (this.timer) | |
222 this.timer.stop(); | |
223 this.timer = setInterval(function() { self.update();}, frame_interval); | |
224 this.startmove = Date.now()+this.starttime*1000; | |
225 this.end = this.startmove+this.duration*1000; | |
226 } | |
227 function linear_stop() | |
228 { | |
229 if (this.timer) { | |
230 this.timer.stop(); | |
231 this.timer = null; | |
232 } | |
233 } | |
234 | |
235 function linear_finish() | |
236 { | |
237 this.action.draw(1); | |
238 } | |
239 function linear(action,start, duration) | |
240 { | |
241 this.action = action; | |
242 this.duration = duration; | |
243 this.starttime = start; | |
244 this.timer=null; | |
245 } | |
246 linear.prototype.update = linear_update; | |
247 linear.prototype.start = linear_start; | |
248 linear.prototype.stop = linear_stop; | |
249 linear.prototype.finish = linear_finish; | |
250 exports.linear = linear; | |
251 | |
252 | |
253 function program(words) | |
254 { | |
255 this.words = wrods; | |
256 } | |
257 | |
258 program.prototype.start=function() { | |
259 for(w in this.words) { | |
260 w.start(); | |
261 } | |
262 } | |
263 | |
264 program.prototype.stop=function(s) { | |
265 for(w in this.words) { | |
266 w.stop(); | |
267 } | |
268 } | |
269 program.prototype.finish=function() { | |
270 for(w in this.words) { | |
271 w.finish(); | |
272 } | |
273 } | |
274 | |
275 exports.run = function(actions,start,duration) { | |
276 for(a in actions) { | |
277 var li = new linear(actions[a],start,duration); | |
278 sys.puts(li); | |
279 li.start(); | |
280 } | |
281 } | |
282 exports.runexp=function(actions,start,exp) { | |
283 } |