annotate nodejs/testsvg.js @ 744:6a988e23ad2a

A dirty implementation of removing subtree
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 25 Aug 2010 14:23:06 +0800
parents 6879aa403306
children caa2fdb5f220
rev   line source
714
f53e45d1fcd0 Translate the svg.js as a nodejs module.
wycc
parents:
diff changeset
1 var svg = require("./svg");
716
72abb4154936 Add mbapp module
wycc
parents: 714
diff changeset
2 var mbapp = require("./mbapp");
721
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
3 var sys=require("sys");
727
468cd504800c Rewrite the animation as a module.
wycc
parents: 726
diff changeset
4 var animate=require("./animate");
732
6879aa403306 Add set_text to the coordinate of the coord_t of the text.
wycc
parents: 730
diff changeset
5 var fs = require("fs");
714
f53e45d1fcd0 Translate the svg.js as a nodejs module.
wycc
parents:
diff changeset
6
716
72abb4154936 Add mbapp module
wycc
parents: 714
diff changeset
7 app = new mbapp.app();
72abb4154936 Add mbapp module
wycc
parents: 714
diff changeset
8 app.loadSVG("test.svg");
723
8af3b87b502e Correct syntax if a statement
Thinker K.F. Li <thinker@branda.to>
parents: 722
diff changeset
9 lightbar = app.get("item_lightbar");
8af3b87b502e Correct syntax if a statement
Thinker K.F. Li <thinker@branda.to>
parents: 722
diff changeset
10 item=1;
8af3b87b502e Correct syntax if a statement
Thinker K.F. Li <thinker@branda.to>
parents: 722
diff changeset
11 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
12
732
6879aa403306 Add set_text to the coordinate of the coord_t of the text.
wycc
parents: 730
diff changeset
13 app.files=fs.readdirSync("/tmp/");
6879aa403306 Add set_text to the coordinate of the coord_t of the text.
wycc
parents: 730
diff changeset
14 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
15 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
16 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
17 }
6879aa403306 Add set_text to the coordinate of the coord_t of the text.
wycc
parents: 730
diff changeset
18
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
730
e77ae2d23245 Add addKeyListener to handle key input.
wycc
parents: 729
diff changeset
22 app.addKeyListener(mbapp.KEY_UP, function() {
721
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
23 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
24 if (item == 0) item = 1;
727
468cd504800c Rewrite the animation as a module.
wycc
parents: 726
diff changeset
25 else {
468cd504800c Rewrite the animation as a module.
wycc
parents: 726
diff changeset
26 var target = app.get("item"+item);
728
a843f147c995 Add Y coordiante in the linear animation.
wycc
parents: 727
diff changeset
27 var an = new animate.linear(app,lightbar,target[2],target[5],0.3);
727
468cd504800c Rewrite the animation as a module.
wycc
parents: 726
diff changeset
28 an.start();
468cd504800c Rewrite the animation as a module.
wycc
parents: 726
diff changeset
29 }
730
e77ae2d23245 Add addKeyListener to handle key input.
wycc
parents: 729
diff changeset
30 });
e77ae2d23245 Add addKeyListener to handle key input.
wycc
parents: 729
diff changeset
31
e77ae2d23245 Add addKeyListener to handle key input.
wycc
parents: 729
diff changeset
32 app.addKeyListener(mbapp.KEY_DOWN, function() {
721
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
33 item = item + 1;
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
34 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
35 item = 9;
727
468cd504800c Rewrite the animation as a module.
wycc
parents: 726
diff changeset
36 } else {
468cd504800c Rewrite the animation as a module.
wycc
parents: 726
diff changeset
37 var target = app.get("item"+item);
728
a843f147c995 Add Y coordiante in the linear animation.
wycc
parents: 727
diff changeset
38 var an = new animate.linear(app,lightbar,target[2],target[5],0.3);
727
468cd504800c Rewrite the animation as a module.
wycc
parents: 726
diff changeset
39 an.start();
468cd504800c Rewrite the animation as a module.
wycc
parents: 726
diff changeset
40 }
721
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
41 });
730
e77ae2d23245 Add addKeyListener to handle key input.
wycc
parents: 729
diff changeset
42
716
72abb4154936 Add mbapp module
wycc
parents: 714
diff changeset
43 app.loop();