Mercurial > MadButterfly
comparison nodejs/testdesktop.js @ 855:c385493e04b6 abs_n_rel_center
Re-indent
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 20 Sep 2010 22:43:43 +0800 |
parents | dfe28355bded |
children | 88f4916a0691 |
comparison
equal
deleted
inserted
replaced
854:eff2f580b536 | 855:c385493e04b6 |
---|---|
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- | |
1 // vim: sw=4:ts=8:sts=4 | 2 // vim: sw=4:ts=8:sts=4 |
2 var svg = require("./svg"); | 3 var svg = require("./svg"); |
3 var mbapp = require("./mbapp"); | 4 var mbapp = require("./mbapp"); |
4 var sys=require("sys"); | 5 var sys=require("sys"); |
5 var animate=require("./animate"); | 6 var animate=require("./animate"); |
16 setting = app.get("setting"); | 17 setting = app.get("setting"); |
17 | 18 |
18 lightbar = app.get("lightbar"); | 19 lightbar = app.get("lightbar"); |
19 lines=[app.get("line1"),app.get("line2"),app.get("line3"), app.get("line4"),app.get("line5")]; | 20 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 for(i=0;i<lines.length;i++) { |
21 sys.puts("["+i+"]="+lines[i].y); | 22 sys.puts("["+i+"]="+lines[i].center.x); |
22 } | 23 } |
23 line=0; | 24 line=0; |
24 | 25 |
25 items=[video,audio,picture,setting]; | 26 items=[video,audio,picture,setting]; |
26 item = 0; | 27 item = 0; |
27 an = new animate.scale(app,items[item],1,1.5,0.1); | 28 an = new animate.scale(app,items[item],1,1.5,0.1); |
28 an.start(); | 29 an.start(); |
29 app.refresh(); | 30 app.refresh(); |
30 app.addKeyListener(mbapp.KEY_LEFT, function() { | 31 app.addKeyListener(mbapp.KEY_LEFT, function() { |
31 var old = items[item]; | 32 var old = items[item]; |
32 item = item - 1; | 33 item = item - 1; |
33 if (item == -1) { | 34 if (item == -1) { |
34 item = 0; | 35 item = 0; |
35 return; | 36 return; |
36 } | 37 } |
37 var target = items[item]; | 38 var target = items[item]; |
38 var an = new animate.scale(app,old,1,1,0.1); | 39 var an = new animate.scale(app,old,1,1,0.1); |
39 an.start(); | 40 an.start(); |
40 an = new animate.scale(app,target,1,1.5,0.3); | 41 an = new animate.scale(app,target,1,1.5,0.3); |
41 an.start(); | 42 an.start(); |
42 }); | 43 }); |
43 | 44 |
44 app.addKeyListener(mbapp.KEY_RIGHT, function() { | 45 app.addKeyListener(mbapp.KEY_RIGHT, function() { |
45 var old = items[item]; | 46 var old = items[item]; |
46 item = item + 1; | 47 item = item + 1; |
47 if (item == items.length) { | 48 if (item == items.length) { |
48 item = item - 1; | 49 item = item - 1; |
49 return; | 50 return; |
50 } | 51 } |
51 var target = items[item]; | 52 var target = items[item]; |
52 var an = new animate.scale(app,old,1,1,0.1); | 53 var an = new animate.scale(app,old,1,1,0.1); |
53 an.start(); | 54 an.start(); |
54 an = new animate.scale(app,target,1,1.5,0.3); | 55 an = new animate.scale(app,target,1,1.5,0.3); |
55 an.start(); | 56 an.start(); |
56 }); | 57 }); |
57 | 58 |
58 app.addKeyListener(mbapp.KEY_UP, function() { | 59 app.addKeyListener(mbapp.KEY_UP, function() { |
59 var old = lines[line]; | 60 var old = lines[line]; |
60 line = line - 1; | 61 line = line - 1; |
61 if (line == -1) { | 62 if (line == -1) { |
62 line = 0; | 63 line = 0; |
63 return; | 64 return; |
64 } | 65 } |
65 var target = lines[line]; | 66 var target = lines[line]; |
66 var sy = target.y-20-lightbar.y; | 67 var sy = target.center.y - 20 - lightbar.center.y; |
67 sys.puts(sy); | 68 sys.puts(sy); |
68 var an = new animate.linear(app,lightbar,0,sy,0.3); | 69 var an = new animate.linear(app,lightbar,0,sy,0.3); |
69 an.start(); | 70 an.start(); |
70 }); | 71 }); |
71 app.addKeyListener(mbapp.KEY_DOWN, function() { | 72 app.addKeyListener(mbapp.KEY_DOWN, function() { |
72 var old = lines[line]; | 73 var old = lines[line]; |
73 line = line + 1; | 74 line = line + 1; |
74 if (line == lines.length) { | 75 if (line == lines.length) { |
75 line = line - 1; | 76 line = line - 1; |
76 return; | 77 return; |
77 } | 78 } |
78 var target = lines[line]; | 79 var target = lines[line]; |
79 var sy = target.y-20-lightbar.y; | 80 sys.puts(target); |
80 sys.puts("line="+line); | 81 var sy = target.cnter.y - 20 - lightbar.center.y; |
81 sys.puts("sy="+sy); | 82 sys.puts("line="+line); |
82 sys.puts("target.y="+target.y); | 83 sys.puts("sy="+sy); |
83 sys.puts("lightbar.y="+lightbar.y); | 84 sys.puts("target.y="+target.center.y); |
84 var an = new animate.linear(app,lightbar,0,sy,0.3); | 85 sys.puts("lightbar.y="+lightbar.center.y); |
85 an.start(); | 86 var an = new animate.linear(app,lightbar,0,sy,0.3); |
87 an.start(); | |
86 }); | 88 }); |
87 | 89 |
88 app.addKeyListener(mbapp.KEY_ENTER, function() { | 90 app.addKeyListener(mbapp.KEY_ENTER, function() { |
89 var target = items[item]; | 91 var target = items[item]; |
90 var sx = 500-target.x; | 92 var sx = 500 - target.center.x; |
91 var sy = 220-target.y; | 93 var sy = 220 - target.center.y; |
92 sys.puts("target "+sx+','+sy); | 94 sys.puts("target "+sx+','+sy); |
93 var an = new animate.linear(app,target,sx,sy,1); | 95 var an = new animate.linear(app,target,sx,sy,1); |
96 an.start(); | |
97 for(i=0;i<items.length;i++) { | |
98 if (i == item) continue; | |
99 var x = Math.random(); | |
100 var y = Math.random(); | |
101 if (x > 0.5) x = 900; | |
102 else x = -500; | |
103 if (y > 0.5) y = 900; | |
104 else y = -500; | |
105 sx = x - items[i].center.x; | |
106 sy = y - items[i].center.y; | |
107 an = new animate.linear(app,items[i], sx,sy,2); | |
94 an.start(); | 108 an.start(); |
95 for(i=0;i<items.length;i++) { | 109 alpha = new animate.alpha(app,items[i],0, 1); |
96 if (i == item) continue; | 110 alpha.start(); |
97 var x = Math.random(); | 111 } |
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 } | |
110 }); | 112 }); |
111 | 113 |
112 app.loop(); | 114 app.loop(); |