Mercurial > MadButterfly
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 | 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 |
752 | 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 | 20 an = new animate.scale(app,items[item],1,1.5,0.1); |
752 | 21 an.start(); |
845 | 22 app.refresh(); |
820 | 23 setInterval(function() { |
24 | |
752 | 25 |
820 | 26 }, 300); |
27 app.addKeyListener(mbapp.KEY_LEFT, function() { | |
752 | 28 var old = items[item]; |
29 item = item - 1; | |
30 if (item == -1) { | |
31 item = 0; | |
32 return; | |
33 } | |
845 | 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 | 36 an.start(); |
801 | 37 an = new animate.scale(app,target,1,1.5,0.3); |
845 | 38 an.start(); |
752 | 39 }); |
40 | |
820 | 41 app.addKeyListener(mbapp.KEY_RIGHT, function() { |
752 | 42 var old = items[item]; |
43 item = item + 1; | |
44 if (item == items.length) { | |
45 item = item - 1; | |
46 return; | |
47 } | |
845 | 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 | 50 an.start(); |
801 | 51 an = new animate.scale(app,target,1,1.5,0.3); |
845 | 52 an.start(); |
53 }); | |
54 | |
55 | |
56 app.addKeyListener(mbapp.KEY_ENTER, function() { | |
57 var target = items[item]; | |
58 var sx = 500-target.x; | |
59 var sy = 220-target.y; | |
60 sys.puts("target "+sx+','+sy); | |
61 var an = new animate.linear(app,target,sx,sy,1); | |
62 an.start(); | |
63 for(i=0;i<items.length;i++) { | |
64 if (i == item) continue; | |
65 var x = Math.random(); | |
66 var y = Math.random(); | |
67 if (x > 0.5) x = 900; | |
68 else x = -500; | |
69 if (y > 0.5) y = 900; | |
70 else y = -500; | |
71 sx = x-items[i].x; | |
72 sy = y-items[i].y; | |
73 an = new animate.linear(app,items[i], sx,sy,2); | |
74 an.start(); | |
75 alpha = new animate.alpha(app,items[i],0, 1); | |
76 alpha.start(); | |
77 } | |
752 | 78 }); |
79 | |
80 app.loop(); |