changeset 882:d9d55bb50679 abs_n_rel_center

Parse color and stroke width of tspan object correctly. Color and stroke width may inherited from parent node, a text. We can not use loadSVG._set_paint() that only parse current node. loadSVG._set_paint_style() are used to used inherited style by passing an aggreagated style.
author Thinker K.F. Li <thinker@codemud.net>
date Sat, 25 Sep 2010 20:31:53 +0800
parents a17c4e231e54
children 47a8086e7729
files nodejs/svg.js
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/nodejs/svg.js	Sat Sep 25 20:12:45 2010 +0800
+++ b/nodejs/svg.js	Sat Sep 25 20:31:53 2010 +0800
@@ -229,7 +229,7 @@
     tcoord.set_text = tspan_set_text;
     tcoord.text = obj;
     
-    this._set_paint(n, obj);
+    this._set_paint_style(style, obj);
     this._set_bbox(n, obj);
     
     make_mbnames(this.mb_rt, n, tcoord);
@@ -650,8 +650,7 @@
     return 1;
 }
 
-loadSVG.prototype._set_paint = function(node, tgt) {
-    var style;
+loadSVG.prototype._set_paint_style = function(style, tgt) {
     var paint;
     var fill_alpha = 1;
     var stroke_alpha = 1;
@@ -662,7 +661,6 @@
     var black_paint;
     var i;
     
-    style = parse_style(node);
     if(style) {
 	if('opacity' in style)
 	    alpha = parseFloat(style['opacity']);
@@ -703,6 +701,13 @@
     tgt.stroke_width = stroke_width;
 };
 
+loadSVG.prototype._set_paint = function(node, tgt) {
+    var style;
+
+    style = parse_style(node);
+    this._set_paint_style(style, tgt);
+};
+
 function formalize_path_data(d) {
     var posM, posm;
     var pos;