annotate nodejs/testdesktop.js @ 845:2101a355acba

Use the new animate.linear
author wycc
date Sun, 19 Sep 2010 11:37:28 +0800
parents 586e50f82c1f
children dfe28355bded
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
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
2 var svg = require("./svg");
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
3 var mbapp = require("./mbapp");
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
4 var sys=require("sys");
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
5 var animate=require("./animate");
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
6 var fs = require("fs");
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
7
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
8 app = new mbapp.app();
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
9 app.loadSVG("desktop.svg");
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
10
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
11 video = app.get("video");
845
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
12 //var an = new animate.alpha(app,video,0,1);
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
13 //an.start();
752
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
14 audio = app.get("audio");
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
15 picture = app.get("picture");
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
16 setting = app.get("setting");
845
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
17
752
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
18 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
19 item = 0;
801
f84ccf1f59ae Add icons for the menu demo
wycc
parents: 776
diff changeset
20 an = new animate.scale(app,items[item],1,1.5,0.1);
752
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
21 an.start();
845
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
22 app.refresh();
820
7875e8026e86 Change the key from up/down to left/right
wycc
parents: 801
diff changeset
23 setInterval(function() {
7875e8026e86 Change the key from up/down to left/right
wycc
parents: 801
diff changeset
24
752
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
25
820
7875e8026e86 Change the key from up/down to left/right
wycc
parents: 801
diff changeset
26 }, 300);
7875e8026e86 Change the key from up/down to left/right
wycc
parents: 801
diff changeset
27 app.addKeyListener(mbapp.KEY_LEFT, function() {
752
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
28 var old = items[item];
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
29 item = item - 1;
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
30 if (item == -1) {
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
31 item = 0;
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
32 return;
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
33 }
845
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
34 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
35 var an = new animate.scale(app,old,1,1,0.1);
845
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
36 an.start();
801
f84ccf1f59ae Add icons for the menu demo
wycc
parents: 776
diff changeset
37 an = new animate.scale(app,target,1,1.5,0.3);
845
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
38 an.start();
752
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
39 });
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
40
820
7875e8026e86 Change the key from up/down to left/right
wycc
parents: 801
diff changeset
41 app.addKeyListener(mbapp.KEY_RIGHT, function() {
752
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
42 var old = items[item];
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
43 item = item + 1;
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
44 if (item == items.length) {
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
45 item = item - 1;
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
46 return;
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
47 }
845
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
48 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
49 var an = new animate.scale(app,old,1,1,0.1);
845
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
50 an.start();
801
f84ccf1f59ae Add icons for the menu demo
wycc
parents: 776
diff changeset
51 an = new animate.scale(app,target,1,1.5,0.3);
845
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
52 an.start();
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
53 });
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
54
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
55
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
56 app.addKeyListener(mbapp.KEY_ENTER, function() {
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
57 var target = items[item];
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
58 var sx = 500-target.x;
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
59 var sy = 220-target.y;
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
60 sys.puts("target "+sx+','+sy);
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
61 var an = new animate.linear(app,target,sx,sy,1);
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
62 an.start();
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
63 for(i=0;i<items.length;i++) {
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
64 if (i == item) continue;
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
65 var x = Math.random();
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
66 var y = Math.random();
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
67 if (x > 0.5) x = 900;
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
68 else x = -500;
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
69 if (y > 0.5) y = 900;
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
70 else y = -500;
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
71 sx = x-items[i].x;
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
72 sy = y-items[i].y;
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
73 an = new animate.linear(app,items[i], sx,sy,2);
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
74 an.start();
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
75 alpha = new animate.alpha(app,items[i],0, 1);
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
76 alpha.start();
2101a355acba Use the new animate.linear
wycc
parents: 822
diff changeset
77 }
752
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
78 });
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
79
ffbf9910213c Add testdesktop,js example.
wycc
parents:
diff changeset
80 app.loop();