changeset 845:2101a355acba

Use the new animate.linear
author wycc
date Sun, 19 Sep 2010 11:37:28 +0800
parents 3c48a77b75d3
children f348a41e1aae
files nodejs/desktop.svg nodejs/testdesktop.js
diffstat 2 files changed, 162 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/nodejs/desktop.svg	Sun Sep 19 11:36:42 2010 +0800
+++ b/nodejs/desktop.svg	Sun Sep 19 11:37:28 2010 +0800
@@ -14,10 +14,17 @@
    height="480"
    id="svg2"
    version="1.1"
-   inkscape:version="0.47+devel r9312"
+   inkscape:version="0.47 r22583"
    sodipodi:docname="desktop.svg">
   <defs
      id="defs4">
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 240 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="744.09448 : 240 : 1"
+       inkscape:persp3d-origin="372.04724 : 160 : 1"
+       id="perspective21" />
     <linearGradient
        inkscape:collect="always"
        id="linearGradient3706">
@@ -39,6 +46,13 @@
        x2="747.27411"
        y2="240"
        gradientUnits="userSpaceOnUse" />
+    <inkscape:perspective
+       id="perspective3711"
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+       inkscape:vp_z="1 : 0.5 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="0 : 0.5 : 1"
+       sodipodi:type="inkscape:persp3d" />
   </defs>
   <sodipodi:namedview
      id="base"
@@ -48,10 +62,10 @@
      inkscape:pageopacity="0.0"
      inkscape:pageshadow="2"
      inkscape:zoom="0.98994949"
-     inkscape:cx="-11.924392"
-     inkscape:cy="177.14286"
+     inkscape:cx="141.17351"
+     inkscape:cy="136.92749"
      inkscape:document-units="px"
-     inkscape:current-layer="layer1"
+     inkscape:current-layer="svg2"
      showgrid="false"
      inkscape:window-width="1920"
      inkscape:window-height="1006"
@@ -73,7 +87,14 @@
   <g
      inkscape:groupmode="layer"
      id="layer3"
-     inkscape:label="background">
+     inkscape:label="background"
+     sodipodi:insensitive="true"
+     inkscape:transform-center-x="0"
+     inkscape:transform-center-y="0"
+     inkscape:bbox-x="0"
+     inkscape:bbox-y="0"
+     inkscape:bbox-width="747.27411"
+     inkscape:bbox-height="480">
     <rect
        style="fill:url(#linearGradient3712);fill-opacity:1"
        id="rect2928"
@@ -81,64 +102,139 @@
        height="480"
        x="0"
        y="0"
-       ry="3.0304577" />
+       ry="3.0304577"
+       inkscape:transform-center-x="0"
+       inkscape:transform-center-y="0"
+       inkscape:bbox-x="0"
+       inkscape:bbox-y="0"
+       inkscape:bbox-width="747.27411"
+       inkscape:bbox-height="480" />
   </g>
   <g
      inkscape:label="Layer 1"
      inkscape:groupmode="layer"
      id="layer1"
-     transform="translate(0,-572.36218)">
+     inkscape:transform-center-x="0"
+     inkscape:transform-center-y="0"
+     inkscape:bbox-x="35.355339"
+     inkscape:bbox-y="249.90203"
+     inkscape:bbox-width="641.44684"
+     inkscape:bbox-height="219.19541"
+     style="display:inline">
     <g
        id="g2917"
-       transform="translate(34.345189,-8.0812203)"
-       mbname="video">
+       transform="translate(-27.274116,-798.02051)"
+       mbname="video"
+       inkscape:transform-center-x="0"
+       inkscape:transform-center-y="0"
+       inkscape:bbox-x="35.992421"
+       inkscape:bbox-y="383.87928"
+       inkscape:bbox-width="85.598946"
+       inkscape:bbox-height="84.588799">
       <image
          sodipodi:absref="/home/wycc/devel/md3/MadButterfly/nodejs/video.png"
          xlink:href="video.png"
-         width="85.598946"
-         height="84.588799"
+         inkscape:bbox-height="84.588799"
+         inkscape:bbox-width="85.598946"
+         inkscape:bbox-y="383.87928"
+         inkscape:bbox-x="35.992421"
+         inkscape:transform-center-y="0"
+         inkscape:transform-center-x="0"
+         y="809.55243"
+         x="63.266537"
          id="image2983"
-         x="63.266537"
-         y="809.55243" />
+         height="84.588799"
+         width="85.598946" />
     </g>
     <g
        id="g2917-8"
-       transform="translate(194.45437,-7.071074)"
-       mbname="audio">
+       transform="translate(126.77414,-798.02053)"
+       mbname="audio"
+       inkscape:transform-center-x="0"
+       inkscape:transform-center-y="0"
+       inkscape:bbox-x="189.7836"
+       inkscape:bbox-y="386.37278"
+       inkscape:bbox-width="86.5"
+       inkscape:bbox-height="76.928574">
       <image
          sodipodi:absref="/home/wycc/devel/md3/MadButterfly/nodejs/music.png"
          xlink:href="music.png"
-         width="86.5"
-         height="76.928574"
+         inkscape:bbox-height="76.928574"
+         inkscape:bbox-width="86.5"
+         inkscape:bbox-y="386.37278"
+         inkscape:bbox-x="189.7836"
+         inkscape:transform-center-y="0"
+         inkscape:transform-center-x="0"
+         y="814.71918"
+         x="63.00946"
          id="image3048"
-         x="63.00946"
-         y="814.71918" />
+         height="76.928574"
+         width="86.5" />
     </g>
     <g
        id="g2917-88"
-       transform="translate(346.22978,-8.0812213)"
-       mbname="picture">
+       transform="translate(290.67139,-799.03067)"
+       mbname="picture"
+       inkscape:transform-center-x="0"
+       inkscape:transform-center-y="0"
+       inkscape:bbox-x="354.2955"
+       inkscape:bbox-y="392.95458"
+       inkscape:bbox-width="84"
+       inkscape:bbox-height="76.14286">
       <image
          sodipodi:absref="/home/wycc/devel/md3/MadButterfly/nodejs/photo.png"
          xlink:href="photo.png"
-         width="84"
-         height="76.14286"
+         inkscape:bbox-height="76.14286"
+         inkscape:bbox-width="84"
+         inkscape:bbox-y="392.95458"
+         inkscape:bbox-x="354.2955"
+         inkscape:transform-center-y="0"
+         inkscape:transform-center-x="0"
+         y="809.93323"
+         x="63.624115"
          id="image3049"
-         x="63.624115"
-         y="809.93323" />
+         height="76.14286"
+         width="84" />
     </g>
     <g
        id="g2917-8-6"
-       transform="translate(494.21713,-6.0609263)"
-       mbname="setting">
+       transform="translate(462.9024,-794.99007)"
+       mbname="setting"
+       inkscape:transform-center-x="0"
+       inkscape:transform-center-y="0"
+       inkscape:bbox-x="526.42387"
+       inkscape:bbox-y="389.0568"
+       inkscape:bbox-width="84.571426"
+       inkscape:bbox-height="75.14286">
       <image
          sodipodi:absref="/home/wycc/devel/md3/MadButterfly/nodejs/tool.png"
          xlink:href="tool.png"
-         width="84.571426"
-         height="75.14286"
+         inkscape:bbox-height="75.14286"
+         inkscape:bbox-width="84.571426"
+         inkscape:bbox-y="389.0568"
+         inkscape:bbox-x="526.42387"
+         inkscape:transform-center-y="0"
+         inkscape:transform-center-x="0"
+         y="810.79041"
+         x="63.521473"
          id="image3168"
-         x="63.521473"
-         y="810.79041" />
+         height="75.14286"
+         width="84.571426" />
     </g>
+    <rect
+       style="fill:#dfdf49;fill-opacity:1"
+       id="rect2929"
+       width="641.44684"
+       height="71.720833"
+       x="35.355339"
+       y="158.37714"
+       inkscape:transform-center-x="0"
+       inkscape:transform-center-y="0"
+       rx="10"
+       ry="10"
+       inkscape:bbox-x="35.355339"
+       inkscape:bbox-y="249.90203"
+       inkscape:bbox-width="641.44684"
+       inkscape:bbox-height="71.720833" />
   </g>
 </svg>
--- a/nodejs/testdesktop.js	Sun Sep 19 11:36:42 2010 +0800
+++ b/nodejs/testdesktop.js	Sun Sep 19 11:37:28 2010 +0800
@@ -1,4 +1,3 @@
-// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
 // vim: sw=4:ts=8:sts=4
 var svg = require("./svg");
 var mbapp = require("./mbapp");
@@ -10,13 +9,17 @@
 app.loadSVG("desktop.svg");
 
 video = app.get("video");
+//var an = new animate.alpha(app,video,0,1);
+//an.start();
 audio = app.get("audio");
 picture = app.get("picture");
 setting = app.get("setting");
+
 items=[video,audio,picture,setting];
 item = 0;
 an = new animate.scale(app,items[item],1,1.5,0.1);
 an.start();
+app.refresh();
 setInterval(function() {
     
 
@@ -28,11 +31,11 @@
 		item = 0;
 		return;
 	}
-    var target = items[item];
+        var target = items[item];
 	var an = new animate.scale(app,old,1,1,0.1);
-    an.start();
+        an.start();
 	an = new animate.scale(app,target,1,1.5,0.3);
-    an.start();
+        an.start();
 });
 
 app.addKeyListener(mbapp.KEY_RIGHT, function() {
@@ -42,11 +45,36 @@
 		item = item - 1;
 		return;
 	}
-    var target = items[item];
+        var target = items[item];
 	var an = new animate.scale(app,old,1,1,0.1);
-    an.start();
+        an.start();
 	an = new animate.scale(app,target,1,1.5,0.3);
-    an.start();
+        an.start();
+});
+
+
+app.addKeyListener(mbapp.KEY_ENTER, function() {
+	var target = items[item];
+	var sx = 500-target.x;
+	var sy = 220-target.y;
+	sys.puts("target "+sx+','+sy);
+	var an = new animate.linear(app,target,sx,sy,1);
+	an.start();
+	for(i=0;i<items.length;i++) {
+	    if (i == item) continue;
+	    var x = Math.random();
+	    var y = Math.random();
+	    if (x > 0.5) x = 900;
+	    else x = -500;
+	    if (y > 0.5) y = 900;
+	    else y = -500;
+	    sx = x-items[i].x;
+	    sy = y-items[i].y;
+	    an = new animate.linear(app,items[i], sx,sy,2);
+	    an.start();
+	    alpha = new animate.alpha(app,items[i],0, 1);
+	    alpha.start();
+	}
 });
 
 app.loop();