changeset 788:7ec13634c97d

Add holder for animate
author Thinker K.F. Li <thinker@codemud.net>
date Tue, 31 Aug 2010 02:36:01 +0800
parents 0899dcac441c
children 9b2d803701e0
files nodejs/animate.js nodejs/observer.cc nodejs/svg.js
diffstat 3 files changed, 36 insertions(+), 2 deletions(-) [+]
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;
--- a/nodejs/observer.cc	Tue Aug 31 01:26:22 2010 +0800
+++ b/nodejs/observer.cc	Tue Aug 31 02:36:01 2010 +0800
@@ -98,7 +98,7 @@
     Persistent<Object> *hdl;
     
     hdl = (Persistent<Object> *)
-	mb_prop_get(&((mb_obj_t *)evt->tgt)->props,
+	mb_prop_get(&((mb_obj_t *)evt->tgt->obj)->props,
 		    PROP_JSOBJ);
     return Local<Object>::New(*hdl);
 }
@@ -115,7 +115,7 @@
     Persistent<Object> *hdl;
     
     hdl = (Persistent<Object> *)
-	mb_prop_get(&((mb_obj_t *)evt->cur_tgt)->props,
+	mb_prop_get(&((mb_obj_t *)evt->cur_tgt->obj)->props,
 		    PROP_JSOBJ);
     return Local<Object>::New(*hdl);
 }
--- a/nodejs/svg.js	Tue Aug 31 01:26:22 2010 +0800
+++ b/nodejs/svg.js	Tue Aug 31 02:36:01 2010 +0800
@@ -474,6 +474,8 @@
     this._set_paint(n, rect);
     this._set_bbox(n, tcoord);
     tcoord.add_shape(rect);
+
+    make_mbnames(this.mb_rt, n, tcoord);
 };
 
 // When we parse a group, we need to calculate the origin of the group