Mercurial > MadButterfly
comparison nodejs/testdesktop.js @ 906:62ef69e02e85
branch merge
author | Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com> |
---|---|
date | Sun, 03 Oct 2010 18:15:00 +0800 |
parents | 3136db0ac01b |
children |
comparison
equal
deleted
inserted
replaced
905:e3a5e05f00c1 | 906:62ef69e02e85 |
---|---|
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"); |
14 audio = app.get("audio"); | 15 audio = app.get("audio"); |
15 picture = app.get("picture"); | 16 picture = app.get("picture"); |
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 = []; |
20 for(i=0;i<lines.length;i++) { | 21 for(i = 0; i < 5; i++) { |
21 sys.puts("["+i+"]="+lines[i].y); | 22 line = app.get("line" + (i + 1)); |
23 lines.push(line); | |
22 } | 24 } |
23 line=0; | 25 line=0; |
24 | 26 |
25 items=[video,audio,picture,setting]; | 27 items=[video, audio, picture, setting]; |
28 | |
26 item = 0; | 29 item = 0; |
27 an = new animate.scale(app,items[item],1,1.5,0.1); | 30 |
28 an.start(); | 31 animate.run([new animate.scale(app,items[item], 1, 1.5)], 0, 0.1); |
29 app.refresh(); | 32 app.refresh(); |
33 | |
30 app.addKeyListener(mbapp.KEY_LEFT, function() { | 34 app.addKeyListener(mbapp.KEY_LEFT, function() { |
31 var old = items[item]; | 35 var old = items[item]; |
32 item = item - 1; | 36 item = item - 1; |
33 if (item == -1) { | 37 if (item == -1) { |
34 item = 0; | 38 item = 0; |
35 return; | 39 return; |
36 } | 40 } |
37 var target = items[item]; | 41 |
38 var an = new animate.scale(app,old,1,1,0.1); | 42 var target = items[item]; |
39 an.start(); | 43 |
40 an = new animate.scale(app,target,1,1.5,0.3); | 44 old.bbox.update(); |
41 an.start(); | 45 target.bbox.update(); |
46 | |
47 var an = new animate.scale(app, old, 1, 1); | |
48 animate.run([an], 0, 0.1); | |
49 an = new animate.scale(app, target, 1, 1.5); | |
50 animate.run([an], 0, 0.3); | |
42 }); | 51 }); |
43 | 52 |
44 app.addKeyListener(mbapp.KEY_RIGHT, function() { | 53 app.addKeyListener(mbapp.KEY_RIGHT, function() { |
45 var old = items[item]; | 54 var old = items[item]; |
46 item = item + 1; | 55 item = item + 1; |
47 if (item == items.length) { | 56 if (item == items.length) { |
48 item = item - 1; | 57 item = item - 1; |
49 return; | 58 return; |
50 } | 59 } |
51 var target = items[item]; | 60 |
52 var an = new animate.scale(app,old,1,1,0.1); | 61 var target = items[item]; |
53 an.start(); | 62 |
54 an = new animate.scale(app,target,1,1.5,0.3); | 63 old.bbox.update(); |
55 an.start(); | 64 target.bbox.update(); |
65 | |
66 var an = new animate.scale(app, old, 1, 1); | |
67 animate.run([an], 0, 0.1); | |
68 an = new animate.scale(app, target, 1, 1.5); | |
69 animate.run([an], 0, 0.3); | |
56 }); | 70 }); |
57 | 71 |
58 app.addKeyListener(mbapp.KEY_UP, function() { | 72 app.addKeyListener(mbapp.KEY_UP, function() { |
59 var old = lines[line]; | 73 var old = lines[line]; |
60 line = line - 1; | 74 line = line - 1; |
61 if (line == -1) { | 75 if (line == -1) { |
62 line = 0; | 76 line = 0; |
63 return; | 77 return; |
64 } | 78 } |
65 var target = lines[line]; | 79 var target = lines[line]; |
66 var sy = target.y-lightbar.y; | 80 var sy = target.center.y - lightbar.center.y; |
67 sys.puts(sy); | 81 sys.puts(sy); |
68 var an = new animate.linear(app,lightbar,0,sy,0.3); | 82 var an = new animate.shift(app, lightbar, 0, sy); |
69 an.start(); | 83 animate.run([an], 0, 0.3); |
70 }); | 84 }); |
71 app.addKeyListener(mbapp.KEY_DOWN, function() { | 85 app.addKeyListener(mbapp.KEY_DOWN, function() { |
72 var old = lines[line]; | 86 var old = lines[line]; |
73 line = line + 1; | 87 line = line + 1; |
74 if (line == lines.length) { | 88 if (line == lines.length) { |
75 line = line - 1; | 89 line = line - 1; |
76 return; | 90 return; |
77 } | 91 } |
78 var target = lines[line]; | 92 var target = lines[line]; |
79 var sy = target.y-lightbar.y; | 93 var sy = target.center.y - lightbar.center.y; |
80 sys.puts("line="+line); | 94 sys.puts("line="+line); |
81 sys.puts("sy="+sy); | 95 sys.puts("sy="+sy); |
82 sys.puts("target.y="+target.y); | 96 sys.puts("target.y="+target.center.y); |
83 sys.puts("lightbar.y="+lightbar.y); | 97 sys.puts("lightbar.y="+lightbar.center.y); |
84 var an = new animate.linear(app,lightbar,0,sy,0.3); | 98 var an = new animate.shift(app, lightbar, 0, sy); |
85 an.start(); | 99 animate.run([an], 0, 0.3); |
86 }); | 100 }); |
87 | 101 |
88 app.addKeyListener(mbapp.KEY_ENTER, function() { | 102 app.addKeyListener(mbapp.KEY_ENTER, function() { |
89 var target = items[item]; | 103 var target = items[item]; |
90 var sx = 500-target.x; | 104 var sx = 500 - target.center.x; |
91 var sy = 220-target.y; | 105 var sy = 220 - target.center.y; |
92 sys.puts("target "+sx+','+sy); | 106 sys.puts("target "+sx+','+sy); |
93 var an = new animate.linear(app,target,sx,sy,1); | 107 var an = new animate.shift(app,target,sx,sy,1); |
94 an.start(); | 108 an.start(); |
95 for(i=0;i<items.length;i++) { | 109 for(i=0;i<items.length;i++) { |
96 if (i == item) continue; | 110 if (i == item) continue; |
97 var x = Math.random(); | 111 var x = Math.random(); |
98 var y = Math.random(); | 112 var y = Math.random(); |
99 if (x > 0.5) x = 900; | 113 if (x > 0.5) x = 900; |
100 else x = -500; | 114 else x = -500; |
101 if (y > 0.5) y = 900; | 115 if (y > 0.5) y = 900; |
102 else y = -500; | 116 else y = -500; |
103 sx = x-items[i].x; | 117 sx = x - items[i].center.x; |
104 sy = y-items[i].y; | 118 sy = y - items[i].center.y; |
105 an = new animate.linear(app,items[i], sx,sy,2); | 119 an = new animate.shift(app,items[i], sx, sy); |
106 an.start(); | 120 animate.run([an], 0, 2); |
107 alpha = new animate.alpha(app,items[i],0, 1); | 121 alpha = new animate.alpha(app,items[i], 0); |
108 alpha.start(); | 122 animate.run([an], 0, 1); |
109 } | 123 } |
110 }); | 124 }); |
111 | 125 |
112 app.loop(); | 126 app.loop(); |