Mercurial > MadButterfly
annotate 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 |
rev | line source |
---|---|
855 | 1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
820
diff
changeset
|
2 // vim: sw=4:ts=8:sts=4 |
752 | 3 var svg = require("./svg"); |
4 var mbapp = require("./mbapp"); | |
5 var sys=require("sys"); | |
6 var animate=require("./animate"); | |
7 var fs = require("fs"); | |
8 | |
9 app = new mbapp.app(); | |
10 app.loadSVG("desktop.svg"); | |
11 | |
12 video = app.get("video"); | |
845 | 13 //var an = new animate.alpha(app,video,0,1); |
14 //an.start(); | |
752 | 15 audio = app.get("audio"); |
16 picture = app.get("picture"); | |
17 setting = app.get("setting"); | |
845 | 18 |
847 | 19 lightbar = app.get("lightbar"); |
20 lines=[app.get("line1"),app.get("line2"),app.get("line3"), app.get("line4"),app.get("line5")]; | |
21 for(i=0;i<lines.length;i++) { | |
855 | 22 sys.puts("["+i+"]="+lines[i].center.x); |
847 | 23 } |
24 line=0; | |
25 | |
752 | 26 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
|
27 item = 0; |
801 | 28 an = new animate.scale(app,items[item],1,1.5,0.1); |
752 | 29 an.start(); |
845 | 30 app.refresh(); |
820 | 31 app.addKeyListener(mbapp.KEY_LEFT, function() { |
855 | 32 var old = items[item]; |
33 item = item - 1; | |
34 if (item == -1) { | |
35 item = 0; | |
36 return; | |
37 } | |
38 var target = items[item]; | |
39 var an = new animate.scale(app,old,1,1,0.1); | |
40 an.start(); | |
41 an = new animate.scale(app,target,1,1.5,0.3); | |
42 an.start(); | |
752 | 43 }); |
44 | |
820 | 45 app.addKeyListener(mbapp.KEY_RIGHT, function() { |
855 | 46 var old = items[item]; |
47 item = item + 1; | |
48 if (item == items.length) { | |
49 item = item - 1; | |
50 return; | |
51 } | |
52 var target = items[item]; | |
53 var an = new animate.scale(app,old,1,1,0.1); | |
54 an.start(); | |
55 an = new animate.scale(app,target,1,1.5,0.3); | |
56 an.start(); | |
845 | 57 }); |
58 | |
847 | 59 app.addKeyListener(mbapp.KEY_UP, function() { |
855 | 60 var old = lines[line]; |
61 line = line - 1; | |
62 if (line == -1) { | |
63 line = 0; | |
64 return; | |
65 } | |
66 var target = lines[line]; | |
67 var sy = target.center.y - 20 - lightbar.center.y; | |
68 sys.puts(sy); | |
69 var an = new animate.linear(app,lightbar,0,sy,0.3); | |
70 an.start(); | |
847 | 71 }); |
72 app.addKeyListener(mbapp.KEY_DOWN, function() { | |
855 | 73 var old = lines[line]; |
74 line = line + 1; | |
75 if (line == lines.length) { | |
76 line = line - 1; | |
77 return; | |
78 } | |
79 var target = lines[line]; | |
80 sys.puts(target); | |
81 var sy = target.cnter.y - 20 - lightbar.center.y; | |
82 sys.puts("line="+line); | |
83 sys.puts("sy="+sy); | |
84 sys.puts("target.y="+target.center.y); | |
85 sys.puts("lightbar.y="+lightbar.center.y); | |
86 var an = new animate.linear(app,lightbar,0,sy,0.3); | |
87 an.start(); | |
847 | 88 }); |
845 | 89 |
90 app.addKeyListener(mbapp.KEY_ENTER, function() { | |
855 | 91 var target = items[item]; |
92 var sx = 500 - target.center.x; | |
93 var sy = 220 - target.center.y; | |
94 sys.puts("target "+sx+','+sy); | |
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); | |
845 | 108 an.start(); |
855 | 109 alpha = new animate.alpha(app,items[i],0, 1); |
110 alpha.start(); | |
111 } | |
752 | 112 }); |
113 | |
114 app.loop(); |