Mercurial > MadButterfly
annotate nodejs/testdesktop.js @ 870:512204bcafba
Export the function to create a runtime for an existed window for X.
For some application, we need to create and associate a runtime with
an existed window, and free it the runtime without close the window,
later.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 24 Sep 2010 11:19:53 +0800 |
parents | d1c98eb474e1 |
children | 881efcd8a18f 23dffb564ace |
rev | line source |
---|---|
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
820
diff
changeset
|
1 // vim: sw=4:ts=8:sts=4 |
752 | 2 var svg = require("./svg"); |
3 var mbapp = require("./mbapp"); | |
4 var sys=require("sys"); | |
5 var animate=require("./animate"); | |
6 var fs = require("fs"); | |
7 | |
8 app = new mbapp.app(); | |
9 app.loadSVG("desktop.svg"); | |
10 | |
11 video = app.get("video"); | |
845 | 12 //var an = new animate.alpha(app,video,0,1); |
13 //an.start(); | |
752 | 14 audio = app.get("audio"); |
15 picture = app.get("picture"); | |
16 setting = app.get("setting"); | |
845 | 17 |
847 | 18 lightbar = app.get("lightbar"); |
19 lines=[app.get("line1"),app.get("line2"),app.get("line3"), app.get("line4"),app.get("line5")]; | |
20 for(i=0;i<lines.length;i++) { | |
21 sys.puts("["+i+"]="+lines[i].y); | |
22 } | |
23 line=0; | |
24 | |
752 | 25 items=[video,audio,picture,setting]; |
776
77b561bb7929
Implement new algorithm to calculate the origin of the SVG elemnts so that we can implement object resize without changing the position of the object.
wycc
parents:
758
diff
changeset
|
26 item = 0; |
801 | 27 an = new animate.scale(app,items[item],1,1.5,0.1); |
752 | 28 an.start(); |
845 | 29 app.refresh(); |
820 | 30 app.addKeyListener(mbapp.KEY_LEFT, function() { |
752 | 31 var old = items[item]; |
32 item = item - 1; | |
33 if (item == -1) { | |
34 item = 0; | |
35 return; | |
36 } | |
845 | 37 var target = items[item]; |
758
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
752
diff
changeset
|
38 var an = new animate.scale(app,old,1,1,0.1); |
845 | 39 an.start(); |
801 | 40 an = new animate.scale(app,target,1,1.5,0.3); |
845 | 41 an.start(); |
752 | 42 }); |
43 | |
820 | 44 app.addKeyListener(mbapp.KEY_RIGHT, function() { |
752 | 45 var old = items[item]; |
46 item = item + 1; | |
47 if (item == items.length) { | |
48 item = item - 1; | |
49 return; | |
50 } | |
845 | 51 var target = items[item]; |
758
d11b0900f03c
Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
wycc
parents:
752
diff
changeset
|
52 var an = new animate.scale(app,old,1,1,0.1); |
845 | 53 an.start(); |
801 | 54 an = new animate.scale(app,target,1,1.5,0.3); |
845 | 55 an.start(); |
56 }); | |
57 | |
847 | 58 app.addKeyListener(mbapp.KEY_UP, function() { |
59 var old = lines[line]; | |
60 line = line - 1; | |
61 if (line == -1) { | |
62 line = 0; | |
63 return; | |
64 } | |
65 var target = lines[line]; | |
849
d1c98eb474e1
Change the code to fit the change of the center of the transformation point.
wycc
parents:
847
diff
changeset
|
66 var sy = target.y-lightbar.y; |
847 | 67 sys.puts(sy); |
68 var an = new animate.linear(app,lightbar,0,sy,0.3); | |
69 an.start(); | |
70 }); | |
71 app.addKeyListener(mbapp.KEY_DOWN, function() { | |
72 var old = lines[line]; | |
73 line = line + 1; | |
74 if (line == lines.length) { | |
75 line = line - 1; | |
76 return; | |
77 } | |
78 var target = lines[line]; | |
849
d1c98eb474e1
Change the code to fit the change of the center of the transformation point.
wycc
parents:
847
diff
changeset
|
79 var sy = target.y-lightbar.y; |
847 | 80 sys.puts("line="+line); |
81 sys.puts("sy="+sy); | |
82 sys.puts("target.y="+target.y); | |
83 sys.puts("lightbar.y="+lightbar.y); | |
84 var an = new animate.linear(app,lightbar,0,sy,0.3); | |
85 an.start(); | |
86 }); | |
845 | 87 |
88 app.addKeyListener(mbapp.KEY_ENTER, function() { | |
89 var target = items[item]; | |
90 var sx = 500-target.x; | |
91 var sy = 220-target.y; | |
92 sys.puts("target "+sx+','+sy); | |
93 var an = new animate.linear(app,target,sx,sy,1); | |
94 an.start(); | |
95 for(i=0;i<items.length;i++) { | |
96 if (i == item) continue; | |
97 var x = Math.random(); | |
98 var y = Math.random(); | |
99 if (x > 0.5) x = 900; | |
100 else x = -500; | |
101 if (y > 0.5) y = 900; | |
102 else y = -500; | |
103 sx = x-items[i].x; | |
104 sy = y-items[i].y; | |
105 an = new animate.linear(app,items[i], sx,sy,2); | |
106 an.start(); | |
107 alpha = new animate.alpha(app,items[i],0, 1); | |
108 alpha.start(); | |
109 } | |
752 | 110 }); |
111 | |
112 app.loop(); |