# HG changeset patch # User Thinker K.F. Li # Date 1285000836 -28800 # Node ID 3ce9daa9558b9d59b304c2755287f7aa42d52b2f # Parent e69f551e4a37020008e67b2b394529b37a2cfe4b Scale an object according bbox.orig diff -r e69f551e4a37 -r 3ce9daa9558b nodejs/animate.js --- a/nodejs/animate.js Tue Sep 21 00:28:44 2010 +0800 +++ b/nodejs/animate.js Tue Sep 21 00:40:36 2010 +0800 @@ -128,8 +128,8 @@ if (this.end == 1) return; var percent = (Date.now() - this.starttime)/this.duration; if (percent > 1) percent = 1; - var sx = 1 + (this.targetx - 1) * percent; - var sy = 1 + (this.targety - 1) * percent; + var sx = 1 + (this.totalsx - 1) * percent; + var sy = 1 + (this.totalsy - 1) * percent; var sh1 = [1, 0, -this.center_x, 0, 1, -this.center_y]; var sh2 = [1, 0, this.center_x, 0, 1, this.center_y]; var scale=[sx, 0, 0, 0, sy, 0]; @@ -156,25 +156,26 @@ obj.animated_scale = null; } -function scale(app,obj,targetx,targety, duration) { +function scale(app, obj, fact_x, fact_y, duration) { + var bbox; + 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) { } + + bbox = obj.bbox; + bbox.update(); obj.animated_scale = this; this.app = app; this.obj = obj; this.end = 0; this.starttime = Date.now(); - this.targetx = targetx; - this.targety = targety; + this.totalsx = fact_x * bbox.orig.width / bbox.width; + this.totalsy = fact_y * bbox.orig.height / bbox.height; this.duration = duration*1000; this.center_x = obj.center.rel.x; this.center_y = obj.center.rel.y; diff -r e69f551e4a37 -r 3ce9daa9558b nodejs/testdesktop.js --- a/nodejs/testdesktop.js Tue Sep 21 00:28:44 2010 +0800 +++ b/nodejs/testdesktop.js Tue Sep 21 00:40:36 2010 +0800 @@ -17,13 +17,15 @@ setting = app.get("setting"); lightbar = app.get("lightbar"); -lines=[app.get("line1"),app.get("line2"),app.get("line3"), app.get("line4"),app.get("line5")]; -for(i=0;i