Mercurial > MadButterfly
annotate nodejs/testsvg.js @ 800:76470d692bb9
Rotate an icon when it is pressed
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 31 Aug 2010 14:55:25 +0800 |
parents | caa2fdb5f220 |
children | 586e50f82c1f |
rev | line source |
---|---|
775 | 1 // -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- |
2 // vim: sw=4:ts=4:sts=4 | |
714 | 3 var svg = require("./svg"); |
716 | 4 var mbapp = require("./mbapp"); |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
5 var sys=require("sys"); |
727 | 6 var animate=require("./animate"); |
732
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
7 var fs = require("fs"); |
714 | 8 |
716 | 9 app = new mbapp.app(); |
10 app.loadSVG("test.svg"); | |
723
8af3b87b502e
Correct syntax if a statement
Thinker K.F. Li <thinker@branda.to>
parents:
722
diff
changeset
|
11 lightbar = app.get("item_lightbar"); |
8af3b87b502e
Correct syntax if a statement
Thinker K.F. Li <thinker@branda.to>
parents:
722
diff
changeset
|
12 item=1; |
8af3b87b502e
Correct syntax if a statement
Thinker K.F. Li <thinker@branda.to>
parents:
722
diff
changeset
|
13 lightbar[5] = app.get("item"+item)[5]; |
722
f95d58a8edd1
Add javascript-based animation test program. We should make it as module in the future.
wycc
parents:
721
diff
changeset
|
14 |
732
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
15 app.files=fs.readdirSync("/tmp/"); |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
16 for(i=1;i<10;i++) { |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
17 var o = app.get("item"+i+"text"); |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
18 o.set_text(app.files[i]); |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
19 } |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
20 |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
21 |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
22 |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
23 |
730 | 24 app.addKeyListener(mbapp.KEY_UP, function() { |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
25 item = item - 1; |
722
f95d58a8edd1
Add javascript-based animation test program. We should make it as module in the future.
wycc
parents:
721
diff
changeset
|
26 if (item == 0) item = 1; |
727 | 27 else { |
28 var target = app.get("item"+item); | |
728 | 29 var an = new animate.linear(app,lightbar,target[2],target[5],0.3); |
727 | 30 an.start(); |
31 } | |
730 | 32 }); |
33 | |
34 app.addKeyListener(mbapp.KEY_DOWN, function() { | |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
35 item = item + 1; |
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
36 if (item == 10) { |
722
f95d58a8edd1
Add javascript-based animation test program. We should make it as module in the future.
wycc
parents:
721
diff
changeset
|
37 item = 9; |
727 | 38 } else { |
39 var target = app.get("item"+item); | |
728 | 40 var an = new animate.linear(app,lightbar,target[2],target[5],0.3); |
727 | 41 an.start(); |
42 } | |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
43 }); |
730 | 44 |
716 | 45 app.loop(); |