Mercurial > MadButterfly
comparison nodejs/animate.js @ 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.
However, the image does not work here since it does not use the transformation of the group.
author | wycc |
---|---|
date | Mon, 30 Aug 2010 08:56:44 +0800 |
parents | d11b0900f03c |
children | 7ec13634c97d |
comparison
equal
deleted
inserted
replaced
775:caa2fdb5f220 | 776:77b561bb7929 |
---|---|
60 | 60 |
61 function scale_draw() { | 61 function scale_draw() { |
62 if (this.end == 1) return; | 62 if (this.end == 1) return; |
63 var percent = (Date.now() - this.starttime)/this.duration; | 63 var percent = (Date.now() - this.starttime)/this.duration; |
64 if (percent > 1) percent = 1; | 64 if (percent > 1) percent = 1; |
65 //sys.puts("time="+(Date.now()-this.starttime)+" percent="+percent); | |
66 var sx = (this.targetx-this.startsx)*percent+this.startsx; | 65 var sx = (this.targetx-this.startsx)*percent+this.startsx; |
67 var sy = (this.targety-this.startsy)*percent+this.startsy; | 66 var sy = (this.targety-this.startsy)*percent+this.startsy; |
68 var t=[sx,0,0,0,sy,0]; | 67 var t=[sx,0,0,0,sy,0]; |
69 //sys.puts("center="+this.obj.center.x+","+this.obj.center.y); | |
70 this.obj[0] = sx; | 68 this.obj[0] = sx; |
71 this.obj[4] = sy; | 69 this.obj[4] = sy; |
72 this.obj[2] = this.origin_offset_x - (sx-this.startsx)*this.obj.center.x; | 70 this.obj[2] = this.origin_offset_x - (sx-this.startsx)*this.obj.center.x; |
73 this.obj[5] = this.origin_offset_y - (sy-this.startsy)*this.obj.center.y; | 71 this.obj[5] = this.origin_offset_y - (sy-this.startsy)*this.obj.center.y; |
74 //sys.puts("sx="+sx); | |
75 //sys.puts("sy="+sy); | |
76 //sys.puts("offseet x="+this.obj[2]); | |
77 //sys.puts("offseet y="+this.obj[5]); | |
78 | 72 |
79 this.app.refresh(); | 73 this.app.refresh(); |
80 var self = this; | 74 var self = this; |
81 if (percent < 1) { | 75 if (percent < 1) { |
82 this.obj.timer=setTimeout(function() { self.draw();}, 20); | 76 this.obj.timer=setTimeout(function() { self.draw();}, 20); |