changeset 758:d11b0900f03c

Check in the dynamic menu example. Currently, it illustarte a bug in the renderer.
author wycc
date Sat, 28 Aug 2010 17:31:59 +0800
parents f43224bf3524
children ae1ae29348d1
files nodejs/animate.js nodejs/desktop.svg nodejs/testdesktop.js
diffstat 3 files changed, 95 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/nodejs/animate.js	Thu Aug 26 17:54:11 2010 +0800
+++ b/nodejs/animate.js	Sat Aug 28 17:31:59 2010 +0800
@@ -18,7 +18,8 @@
 function linear(app,obj,targetx,targety,duration) {
     try {
         if (obj.animated_linear) {
-	        obj[5] = obj.animated_linear.target;
+	        obj[5] = obj.animated_linear.targety;
+	        obj[2] = obj.animated_linear.targetx;
 			obj.animated_linear.end = 1;
 		}
 	} catch(e) {
@@ -36,7 +37,84 @@
 	this.duration = duration*1000;
 }
 
-
 exports.linear = linear;
 linear.prototype.start = linear_draw;
 linear.prototype.draw = linear_draw;
+
+function multiply(s,d) {
+    var m=[];
+	m[0] = s[0]*d[0]+s[1]*d[3];
+	m[1] = s[0]*d[1]+s[1]*d[4];
+	m[2] = s[0]*d[2]+s[1]*d[5]+s[2];
+	m[3] = s[3]*d[0]+s[4]*d[3];
+	m[4] = s[3]*d[1]+s[4]*d[4];
+	m[5] = s[3]*d[2]+s[4]*d[5]+s[5];
+	s[0] = m[0];
+	s[1] = m[1];
+	s[2] = m[2];
+	s[3] = m[3];
+	s[4] = m[4];
+	s[5] = m[5];
+}
+
+
+function scale_draw() {
+    if (this.end == 1) return;
+    var percent = (Date.now() - this.starttime)/this.duration;
+	if (percent > 1) percent = 1;
+	//sys.puts("time="+(Date.now()-this.starttime)+" percent="+percent);
+    var sx = (this.targetx-this.startsx)*percent+this.startsx;
+    var sy = (this.targety-this.startsy)*percent+this.startsy;
+	var t=[sx,0,0,0,sy,0];
+	//sys.puts("center="+this.obj.center.x+","+this.obj.center.y);
+	this.obj[0] = sx;
+	this.obj[4] = sy;
+	this.obj[2] = this.origin_offset_x - (sx-this.startsx)*this.obj.center.x;
+	this.obj[5] = this.origin_offset_y - (sy-this.startsy)*this.obj.center.y;
+	//sys.puts("sx="+sx);
+	//sys.puts("sy="+sy);
+	//sys.puts("offseet x="+this.obj[2]);
+	//sys.puts("offseet y="+this.obj[5]);
+
+	this.app.refresh();
+	var self = this;
+	if (percent < 1) {
+	    this.obj.timer=setTimeout(function() { self.draw();}, 20);
+		return;
+	}
+	this.app.refresh();
+	this.obj.animated_scale = null;
+}
+
+function scale(app,obj,targetx,targety, duration) {
+    try {
+        if (obj.animated_scale) {
+	        //obj[0] = obj.animated_scale.targetx;
+	        //obj[4] = obj.animated_scale.targety;
+			//obj[2] = obj.animated_scale.final_offset_x;
+			//obj[5] = obj.aninated_scale.final_offset_y;
+			obj.animated_scale.end = 1;
+		}
+	} catch(e) {
+	    
+	}
+	obj.animated_scale = this;
+	this.app = app;
+	this.obj = obj;
+	this.end = 0;
+	this.starttime = Date.now();
+	this.startsx = obj[0];
+	this.startsy = obj[4];
+    this.targetx = targetx;
+	this.targety = targety;
+	this.duration = duration*1000;
+	this.origin_offset_x = obj[2];
+	this.origin_offset_y = obj[5];
+	this.final_offset_x = this.origin_offset_x-(targetx-this.startsx)*obj.center.x;
+	this.final_offset_y = this.origin_offset_y-(targety-this.startsy)*obj.center.y;
+}
+
+
+exports.scale = scale;
+scale.prototype.start = scale_draw;
+scale.prototype.draw = scale_draw;
--- a/nodejs/desktop.svg	Thu Aug 26 17:54:11 2010 +0800
+++ b/nodejs/desktop.svg	Sat Aug 28 17:31:59 2010 +0800
@@ -25,10 +25,10 @@
      inkscape:pageopacity="0.0"
      inkscape:pageshadow="2"
      inkscape:zoom="0.98994949"
-     inkscape:cx="375"
+     inkscape:cx="207.31468"
      inkscape:cy="177.14286"
      inkscape:document-units="px"
-     inkscape:current-layer="layer1"
+     inkscape:current-layer="g2917"
      showgrid="false"
      inkscape:window-width="1920"
      inkscape:window-height="1006"
@@ -43,7 +43,7 @@
         <dc:format>image/svg+xml</dc:format>
         <dc:type
            rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-        <dc:title></dc:title>
+        <dc:title />
       </cc:Work>
     </rdf:RDF>
   </metadata>
@@ -64,6 +64,13 @@
          width="83.842659"
          id="rect2915"
          style="fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+      <path
+         inkscape:connector-curvature="0"
+         d="m 103.62546,874.11263 c -0.25439,-0.0146 -1.27423,-0.0611 -2.26633,-0.10347 -2.073702,-0.0885 -5.075221,-0.32019 -6.043581,-0.4666 -1.06985,-0.16175 -6.44814,-1.37058 -9.54317,-2.14494 -0.45789,-0.11456 -1.2488,-0.30804 -1.75756,-0.42996 -0.91854,-0.22012 -5.67819,-1.39521 -7.539,-1.86127 -7.40372,-1.85437 -8.42064,-2.11619 -8.51884,-2.19332 -0.0637,-0.05 -0.0585,-0.23398 0.0161,-0.57037 0.20631,-0.93049 -0.0566,-2.88711 -0.72207,-5.37327 -0.18182,-0.67931 -0.34973,-1.34137 -0.37314,-1.47124 l -0.0425,-0.23613 0.4172,0 c 2.05901,0 9.71875,1.61191 19.90745,4.18931 2.30627,0.58341 3.71143,0.85763 6.79897,1.32684 5.635929,0.85649 9.076551,1.12987 14.199221,1.12825 4.59803,-0.001 6.15485,-0.14008 9.82133,-0.87451 2.313,-0.46332 3.06079,-0.64392 4.45703,-1.0764 1.21794,-0.37726 1.20247,-0.26634 -0.0289,0.20727 -1.77591,0.68304 -4.618,1.3072 -7.31171,1.60574 -0.61052,0.0677 -1.17022,0.14838 -1.24379,0.17937 -0.4107,0.173 2.51421,0.16852 4.29639,-0.007 3.77286,-0.3707 6.56989,-1.44877 8.18709,-3.15556 0.63675,-0.67202 1.29618,-1.81335 1.29237,-2.2368 -0.002,-0.22204 -0.0168,-0.21216 -0.3023,0.20249 -0.16511,0.23976 -0.4298,0.58305 -0.58818,0.76287 -0.29937,0.33986 -1.91036,1.59838 -2.04605,1.59838 -0.0426,0 -0.49357,-0.31877 -1.00215,-0.70837 -2.87695,-2.20393 -7.99539,-4.20516 -14.51358,-5.67456 -3.48802,-0.78632 -6.60263,-1.29747 -11.562871,-1.89766 -13.38541,-1.61962 -22.91906,-4.89504 -26.55824,-9.12445 -0.30736,-0.35722 -0.75652,-0.87572 -0.99812,-1.15222 -0.52459,-0.60038 -0.97093,-1.28635 -1.25655,-1.93118 -0.29033,-0.65543 -0.3642,-1.95278 -0.14892,-2.61554 0.48399,-1.4901 1.84798,-2.84328 4.14155,-4.10879 l 0.71055,-0.39205 -0.44311,-0.68359 c -0.7445,-1.14851 -1.11393,-2.59778 -0.92661,-3.63511 0.4675,-2.58901 3.14622,-5.24389 7.1417,-7.07814 3.84663,-1.76592 9.08297,-2.90772 15.56266,-3.39348 4.715949,-0.35354 12.507271,-0.32184 19.240621,0.0783 8.66858,0.51511 15.39441,1.63515 19.14812,3.18867 0.50876,0.21057 1.26384,0.50214 1.67793,0.64794 2.59628,0.91416 5.50305,2.55128 7.07192,3.98299 0.82008,0.74838 1.66489,1.79336 2.13304,2.63846 l 0.40247,0.72654 -0.007,1.16247 c -0.006,0.94478 -0.044,1.26689 -0.20259,1.72011 -0.27636,0.78997 -0.7025,1.56072 -1.26915,2.29552 l -0.48909,0.63423 0.75539,0.58123 c 0.84114,0.6472 1.34507,1.20374 1.69827,1.87553 0.31411,0.59746 0.39548,1.74858 0.17306,2.44829 -0.95113,2.99215 -6.43662,6.56907 -13.01563,8.48711 -2.31474,0.67484 -4.60161,1.18223 -7.42614,1.64766 -0.80729,0.13302 -1.50787,0.27334 -1.55685,0.31181 -0.0571,0.0448 0.33719,0.29135 1.09777,0.68643 1.38462,0.71921 1.80195,1.02748 2.47534,1.82843 1.40474,1.67083 1.82672,3.43053 1.22983,5.12851 -0.34767,0.989 -0.4281,1.58205 -0.53134,3.91759 -0.0949,2.1472 -0.18579,2.82924 -0.46057,3.45651 -0.3857,0.8805 -0.89924,1.44285 -2.45145,2.68442 -2.13303,1.70615 -5.9228,2.68964 -12.2104,3.16872 -0.98618,0.0752 -7.76089,0.15118 -8.69529,0.0976 z m 17.80683,-21.69381 c -0.70254,-0.46856 -4.69372,-1.77155 -9.11155,-2.97461 -1.01753,-0.2771 -1.93579,-0.53189 -2.04058,-0.56621 -0.58352,-0.19112 -3.84553,-0.93797 -5.57588,-1.27662 -3.70263,-0.72465 -8.287691,-1.49369 -10.606631,-1.77904 -6.86549,-0.84479 -14.52951,-2.99698 -20.97943,-5.89137 -0.90546,-0.40633 -1.66847,-0.72136 -1.69557,-0.70008 -0.19796,0.15549 1.40472,1.28262 3.01811,2.12256 5.36208,2.79156 13.52008,4.82922 25.022059,6.24988 2.550112,0.31497 6.659972,1.00548 10.443522,1.75463 2.40783,0.47676 4.70785,1.10664 10.32341,2.82716 0.68683,0.21043 1.29041,0.3838 1.34129,0.38527 0.0509,10e-4 -0.0116,-0.0667 -0.13875,-0.15157 z m 0.65867,-2.74304 c 0.92817,-0.0964 1.66501,-0.22259 2.34878,-0.40227 6.00955,-1.5792 10.61934,-4.01388 13.08645,-6.91169 0.635,-0.74587 0.80775,-1.0176 0.70047,-1.10185 -0.0319,-0.0251 -0.60808,0.3822 -1.28036,0.90507 -1.46518,1.13957 -1.77874,1.35997 -2.97953,2.09421 -3.42667,2.09531 -7.19375,3.55575 -11.23944,4.35736 -2.01347,0.39895 -4.58535,0.69185 -6.07501,0.69185 -1.17912,0 -0.50162,0.19278 1.26485,0.35991 1.88213,0.17808 2.51938,0.17921 4.17379,0.007 z m -7.96641,-4.80103 c 6.49228,-0.22763 11.28486,-0.88362 16.74303,-2.29172 2.97713,-0.76803 4.55375,-1.25969 6.19307,-1.93123 3.46373,-1.41892 5.63433,-3.14067 6.26053,-4.96598 0.24699,-0.71997 0.11003,-0.83623 -0.23919,-0.20304 -1.3034,2.36327 -5.01454,4.35804 -11.0509,5.93995 -3.8446,1.00754 -9.77358,1.78329 -16.47275,2.15532 -3.51271,0.19508 -9.92327,0.0717 -13.71507,-0.26391 -11.805991,-1.045 -22.101861,-3.88725 -26.622011,-7.34919 -0.92496,-0.70841 -1.42998,-1.24302 -1.89757,-2.00874 -0.69715,-1.14162 -0.80849,-2.32878 -0.33693,-3.5923 0.12304,-0.32966 0.20722,-0.59939 0.18708,-0.59939 -0.0202,0 -0.13808,0.17164 -0.26208,0.38143 -0.75525,1.2778 -0.63679,2.84068 0.32214,4.24991 1.4828,2.17913 5.40568,4.52166 10.66847,6.37065 2.19153,0.76995 3.72549,1.18802 6.91142,1.88368 5.35224,1.16868 10.818551,1.89762 16.152061,2.15389 2.97608,0.14299 4.6301,0.15932 7.1587,0.0707 z m 15.79107,-5.02948 c 0.36278,-0.31163 0.48945,-0.6089 0.48945,-1.14869 0,-0.44242 -0.0429,-0.58336 -0.28681,-0.94283 -0.72988,-1.07556 -2.50786,-2.03487 -4.96908,-2.68109 -2.37559,-0.62372 -4.85835,-0.90065 -8.11079,-0.90467 -2.33702,-0.003 -2.80677,0.0296 -4.7639,0.32948 -3.54567,0.54328 -5.88282,1.80566 -6.07687,3.28235 -0.0552,0.4201 0.19892,1.01511 0.53581,1.25457 0.26484,0.18825 0.30544,0.0823 0.12866,-0.33572 -0.48595,-1.14912 0.67754,-2.13898 3.4012,-2.89367 1.69934,-0.47087 3.41609,-0.69634 6.16076,-0.80913 5.44464,-0.22376 9.77143,0.61992 12.5304,2.44328 1.24025,0.81967 1.37693,1.35889 0.63753,2.5151 -0.0762,0.11919 0.14455,0.0448 0.32364,-0.10898 z m -29.72482,-3.77801 c 0.15671,-0.4593 -0.10946,-1.23499 -0.571892,-1.66663 -0.57256,-0.53444 -2.303489,-1.24398 -3.952969,-1.62039 -2.6714,-0.60962 -6.35859,-0.70132 -9.79752,-0.24366 -2.29359,0.30524 -4.46959,1.07246 -5.36063,1.89007 -0.36977,0.3393 -0.61602,0.87209 -0.54256,1.1739 0.0652,0.26798 0.15428,0.24362 0.34893,-0.0954 0.42625,-0.74242 1.88936,-1.48383 3.65441,-1.85183 1.63655,-0.3412 2.72,-0.43131 5.22642,-0.43464 2.45225,-0.003 3.4313,0.0632 5.44967,0.37009 3.19835,0.48626 4.840169,1.23261 5.245039,2.38431 0.10369,0.29495 0.220172,0.33139 0.301102,0.0942 z m 22.19404,-4.57721 c -0.66518,-0.53424 -0.89456,-0.90927 -0.83815,-1.37039 0.038,-0.3109 0.10508,-0.41374 0.45078,-0.69141 0.76615,-0.61537 2.16217,-1.01229 4.61498,-1.31212 1.50845,-0.18439 4.91882,-0.18341 6.3242,0.002 1.89527,0.24978 3.10127,0.54608 4.44504,1.09208 1.10133,0.44749 2.12283,1.15568 2.31572,1.60544 0.19054,0.44432 0.32797,0.40822 0.32797,-0.0862 0,-0.34602 -0.0507,-0.49049 -0.26509,-0.75607 -0.84538,-1.04699 -3.67842,-2.06269 -6.76514,-2.42544 -3.05227,-0.3587 -6.21069,-0.24473 -9.06159,0.32698 -2.06262,0.41363 -3.61131,1.32485 -3.61131,2.12483 0,0.59429 0.68434,1.21237 1.89631,1.71271 0.61294,0.25304 0.66741,0.18022 0.16628,-0.22226 z m -42.096051,-3.22421 c -0.88363,-0.58185 -0.90194,-1.21885 -0.057,-1.98264 1.38795,-1.25467 7.45011,-1.99262 12.28213,-1.49512 3.21773,0.3313 5.12964,1.01224 5.85164,2.0841 0.1767,0.26231 0.22733,1.01549 0.0955,1.42109 -0.10852,0.33396 0.0437,0.30032 0.46367,-0.1025 0.317609,-0.30461 0.352789,-0.37971 0.350169,-0.74756 -0.0104,-1.46451 -2.711889,-2.62088 -7.054969,-3.01991 -1.37134,-0.12599 -4.98112,-0.14479 -6.41463,-0.0334 -2.55297,0.19837 -4.54502,0.73355 -5.853,1.57246 -1.08792,0.69777 -1.42791,1.37885 -0.97539,1.95394 0.21828,0.27739 1.00219,0.61381 1.42532,0.61168 l 0.28247,-10e-4 -0.39592,-0.26071 z m 40.291491,-1.74966 c 0.47255,-0.17552 1.23208,-0.74987 1.41899,-1.07303 0.21827,-0.37739 0.21569,-0.9379 -0.006,-1.32153 -0.87955,-1.52151 -5.1935,-2.49246 -11.19875,-2.52052 -3.09851,-0.0145 -4.85118,0.21636 -6.52147,0.85895 -1.81649,0.69884 -2.54299,1.58345 -1.99426,2.42826 0.32742,0.50406 1.29631,1.01872 2.33412,1.23983 0.62242,0.13261 0.70387,0.0692 0.24414,-0.19014 -0.69158,-0.39009 -1.4264,-1.02274 -1.54304,-1.3285 -0.23407,-0.61362 0.37986,-1.18444 1.87352,-1.74195 0.95292,-0.35568 2.13599,-0.64829 2.96878,-0.73428 1.19261,-0.12314 4.4673,-0.16681 5.82956,-0.0777 3.14927,0.2059 5.44697,0.72677 6.58268,1.49224 0.50568,0.34082 0.86381,0.90721 0.86381,1.3661 0,0.46011 -0.25607,0.8436 -0.80808,1.21011 -0.24238,0.16094 -0.54477,0.3616 -0.67197,0.44591 l -0.23125,0.15329 0.27751,-0.047 c 0.15263,-0.0258 0.41443,-0.0978 0.58178,-0.16 z"
+         id="path2382-1"
+         style="fill:#d6b1ea;fill-opacity:1"
+         inkscape:transform-center-x="-17.172593"
+         inkscape:transform-center-y="152.53303" />
     </g>
     <g
        id="g2917-8"
--- a/nodejs/testdesktop.js	Thu Aug 26 17:54:11 2010 +0800
+++ b/nodejs/testdesktop.js	Sat Aug 28 17:31:59 2010 +0800
@@ -13,7 +13,7 @@
 setting = app.get("setting");
 items=[video,audio,picture,setting];
 item = 2;
-an = new animate.scale(app,items[item],1,1.5,0.3);
+an = new animate.scale(app,items[item],1,2,0.1);
 an.start();
 
 app.addKeyListener(mbapp.KEY_UP, function() {
@@ -24,9 +24,9 @@
 		return;
 	}
     var target = items[item];
-	var an = new animate.scale(app,old,1,1,0.3);
+	var an = new animate.scale(app,old,1,1,0.1);
     an.start();
-	an = new animate.scale(app,target,1,1.5,0.3);
+	an = new animate.scale(app,target,1,2,0.3);
     an.start();
 });
 
@@ -38,9 +38,9 @@
 		return;
 	}
     var target = items[item];
-	var an = new animate.scale(app,old,1,1,0.3);
+	var an = new animate.scale(app,old,1,1,0.1);
     an.start();
-	an = new animate.scale(app,target,1,1.5,0.3);
+	an = new animate.scale(app,target,1,2,0.3);
     an.start();
 });