Mercurial > MadButterfly
comparison nodejs/animate.js @ 808:9b6c26cf9102
Move bounding box and center back to an object
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 01 Sep 2010 20:04:35 +0800 |
parents | bf54c0408d35 |
children | 586e50f82c1f |
comparison
equal
deleted
inserted
replaced
807:5723e5446b7c | 808:9b6c26cf9102 |
---|---|
85 ang = percent * this._ang; | 85 ang = percent * this._ang; |
86 sv = Math.sin(ang); | 86 sv = Math.sin(ang); |
87 cv = Math.cos(ang); | 87 cv = Math.cos(ang); |
88 mtx = [cv, -sv, 0, sv, cv, 0]; | 88 mtx = [cv, -sv, 0, sv, cv, 0]; |
89 | 89 |
90 shift = [1, 0, -obj.center_x, 0, 1, -obj.center_y]; | 90 shift = [1, 0, -obj.center.x, 0, 1, -obj.center.y]; |
91 mtx = multiply(mtx, shift); | 91 mtx = multiply(mtx, shift); |
92 shift = [1, 0, obj.center_x, 0, 1, obj.center_y]; | 92 shift = [1, 0, obj.center.x, 0, 1, obj.center.y]; |
93 mtx = multiply(shift, mtx); | 93 mtx = multiply(shift, mtx); |
94 mtx = multiply(mtx, this._start_mtx); | 94 mtx = multiply(mtx, this._start_mtx); |
95 | 95 |
96 obj[0] = mtx[0]; | 96 obj[0] = mtx[0]; |
97 obj[1] = mtx[1]; | 97 obj[1] = mtx[1]; |
181 this._coord = coord; | 181 this._coord = coord; |
182 this._app = app; | 182 this._app = app; |
183 } | 183 } |
184 | 184 |
185 holder.prototype = { | 185 holder.prototype = { |
186 go_center: function(o) { | 186 go: function(pos) { |
187 var sx, sy; | 187 var sx, sy; |
188 | 188 |
189 sx = o.center_x - this._coord.center_x; | 189 sx = pos.x - this._coord.center.x; |
190 sy = o.center_y - this._coord.center_y; | 190 sy = pos.y - this._coord.center.y; |
191 this.shift(sx, sy); | 191 this.shift(sx, sy); |
192 }, | 192 }, |
193 | 193 |
194 go_center: function(o) { | |
195 this.go(o.center); | |
196 }, | |
197 | |
194 home: function() { | 198 home: function() { |
195 this._coord[2] = this._mtx[2]; | 199 this._coord[2] = this._mtx[2]; |
196 this._coord[5] = this._mtx[5]; | 200 this._coord[5] = this._mtx[5]; |
197 this._app.refresh(); | 201 this._app.refresh(); |
198 }, | 202 }, |