diff nodejs/animate.js @ 788:7ec13634c97d

Add holder for animate
author Thinker K.F. Li <thinker@codemud.net>
date Tue, 31 Aug 2010 02:36:01 +0800
parents 77b561bb7929
children a27606be2cab
line wrap: on
line diff
--- a/nodejs/animate.js	Tue Aug 31 01:26:22 2010 +0800
+++ b/nodejs/animate.js	Tue Aug 31 02:36:01 2010 +0800
@@ -112,3 +112,35 @@
 exports.scale = scale;
 scale.prototype.start = scale_draw;
 scale.prototype.draw = scale_draw;
+
+function holder(app, coord) {
+    var mtx = [coord[0], coord[1], coord[2], coord[3], coord[4], coord[5]];
+    
+    this._mtx = mtx;
+    this._coord = coord;
+    this._app = app;
+}
+
+holder.prototype = {
+    go_center: function(o) {
+	var sx, sy;
+
+	sx = o.center_x - this._coord.center_x;
+	sy = o.center_y - this._coord.center_y;
+	this.shift(sx, sy);
+    },
+
+    home: function() {
+	this._coord[2] = this._mtx[2];
+	this._coord[5] = this._mtx[5];
+	this._app.refresh();
+    },
+
+    shift: function(sx, sy) {
+	this._coord[2] = this._mtx[2] + sx;
+	this._coord[5] = this._mtx[5] + sy;
+	this._app.refresh();
+    }
+};
+
+exports.holder = holder;