comparison nodejs/svg.js @ 877:deadcca6e213 abs_n_rel_center

Refactory loadSVG._set_paint()
author Thinker K.F. Li <thinker@codemud.net>
date Sat, 25 Sep 2010 15:31:28 +0800
parents e6936110c48f
children 818e5bed913d
comparison
equal deleted inserted replaced
876:e6936110c48f 877:deadcca6e213
626 626
627 return 1; 627 return 1;
628 } 628 }
629 629
630 loadSVG.prototype._set_paint = function(node, tgt) { 630 loadSVG.prototype._set_paint = function(node, tgt) {
631 var style = node.attr('style'); 631 var style;
632 var paint; 632 var paint;
633 var fill_alpha = 1; 633 var fill_alpha = 1;
634 var stroke_alpha = 1; 634 var stroke_alpha = 1;
635 var alpha = 1;
635 var fill_color; 636 var fill_color;
636 var stroke_color; 637 var stroke_color;
637 var black_paint; 638 var black_paint;
638 var i; 639 var i;
639 640
640 if(style != null) { 641 style = parse_style(node);
641 var items = style.value().split(';'); 642 if(style) {
642 var alpha; 643 if('opacity' in style)
643 644 alpha = parseFloat(style['opacity']);
644 for(i in items) { 645 if('fill' in style)
645 var f = items[i].split(':'); 646 fill_color = style['fill'];
646 if (f[0] == 'opacity') { 647 if('fill-opacity' in style)
647 alpha = f[1]; 648 fill_alpha = parseFloat(style['fill-opacity']);
648 } else if (f[0] == 'fill') { 649 if('stroke' in style)
649 fill_color = f[1]; 650 stroke_color = style['stroke'];
650 } else if (f[0] == 'fill-opacity') { 651 if('stroke-width' in style)
651 fill_alpha = parseFloat(f[1]); 652 stroke_width = parseFloat(style['stroke-width']);
652 } else if (f[0] == 'stroke') { 653 if('stroke-opacity' in style)
653 stroke_color = f[1]; 654 stroke_alpha = parseFloat(style['stroke-opacity']);
654 } else if (f[0] == 'stroke-width') { 655 if('display' in style && style['display'] == 'none')
655 tgt.stroke_width = parseFloat(f[1]); 656 return;
656 } else if (f[0] == 'stroke-opacity') {
657 stroke_alpha = parseFloat(f[1]);
658 } else if (f[0] == 'display') {
659 if(f[1] == 'none')
660 return;
661 }
662 }
663
664 } 657 }
665 658
666 if(!fill_color || !stroke_color) 659 if(!fill_color || !stroke_color)
667 black_paint = this.mb_rt.paint_color_new(0, 0, 0, 1); 660 black_paint = this.mb_rt.paint_color_new(0, 0, 0, 1);
668 661