comparison nodejs/svg.js @ 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
comparison
equal deleted inserted replaced
881:a17c4e231e54 882:d9d55bb50679
227 227
228 tcoord.add_shape(obj); 228 tcoord.add_shape(obj);
229 tcoord.set_text = tspan_set_text; 229 tcoord.set_text = tspan_set_text;
230 tcoord.text = obj; 230 tcoord.text = obj;
231 231
232 this._set_paint(n, obj); 232 this._set_paint_style(style, obj);
233 this._set_bbox(n, obj); 233 this._set_bbox(n, obj);
234 234
235 make_mbnames(this.mb_rt, n, tcoord); 235 make_mbnames(this.mb_rt, n, tcoord);
236 }; 236 };
237 237
648 center.update(); 648 center.update();
649 649
650 return 1; 650 return 1;
651 } 651 }
652 652
653 loadSVG.prototype._set_paint = function(node, tgt) { 653 loadSVG.prototype._set_paint_style = function(style, tgt) {
654 var style;
655 var paint; 654 var paint;
656 var fill_alpha = 1; 655 var fill_alpha = 1;
657 var stroke_alpha = 1; 656 var stroke_alpha = 1;
658 var alpha = 1; 657 var alpha = 1;
659 var fill_color; 658 var fill_color;
660 var stroke_color; 659 var stroke_color;
661 var stroke_width = 1; 660 var stroke_width = 1;
662 var black_paint; 661 var black_paint;
663 var i; 662 var i;
664 663
665 style = parse_style(node);
666 if(style) { 664 if(style) {
667 if('opacity' in style) 665 if('opacity' in style)
668 alpha = parseFloat(style['opacity']); 666 alpha = parseFloat(style['opacity']);
669 if('fill' in style) 667 if('fill' in style)
670 fill_color = style['fill']; 668 fill_color = style['fill'];
699 } else { 697 } else {
700 black_paint.stroke(tgt); 698 black_paint.stroke(tgt);
701 } 699 }
702 700
703 tgt.stroke_width = stroke_width; 701 tgt.stroke_width = stroke_width;
702 };
703
704 loadSVG.prototype._set_paint = function(node, tgt) {
705 var style;
706
707 style = parse_style(node);
708 this._set_paint_style(style, tgt);
704 }; 709 };
705 710
706 function formalize_path_data(d) { 711 function formalize_path_data(d) {
707 var posM, posm; 712 var posM, posm;
708 var pos; 713 var pos;