comparison nodejs/svg.js @ 876:e6936110c48f abs_n_rel_center

Fix bug of parsing linear and radial gradient
author Thinker K.F. Li <thinker@codemud.net>
date Sat, 25 Sep 2010 12:09:35 +0800
parents 5d7c3c681851
children deadcca6e213
comparison
equal deleted inserted replaced
875:5d7c3c681851 876:e6936110c48f
573 var vstr; 573 var vstr;
574 var bbox, center; 574 var bbox, center;
575 var orig; 575 var orig;
576 576
577 a = node.attr("bbox-x"); 577 a = node.attr("bbox-x");
578 sys.puts("a="+a);
579 if(!a) 578 if(!a)
580 return 0; 579 return 0;
581 580
582 /* bbox.orig is initial values of bbox. The bbox is recomputed 581 /* bbox.orig is initial values of bbox. The bbox is recomputed
583 * according bbox.orig and current matrix. See bbox.update(). 582 * according bbox.orig and current matrix. See bbox.update().
726 if (c == "tspan") { 725 if (c == "tspan") {
727 this.parseTSpan(tcoord,nodes[k],style); 726 this.parseTSpan(tcoord,nodes[k],style);
728 } else { 727 } else {
729 } 728 }
730 } 729 }
731 sys.puts(y);
732 this._set_bbox(n, tcoord); 730 this._set_bbox(n, tcoord);
733 731
734 make_mbnames(this.mb_rt, n, tcoord); 732 make_mbnames(this.mb_rt, n, tcoord);
735 }; 733 };
736 734
981 opacity = style["stop-opacity"]; 979 opacity = style["stop-opacity"];
982 if(opacity) 980 if(opacity)
983 a = parseFloat(opacity); 981 a = parseFloat(opacity);
984 else 982 else
985 a = 1; 983 a = 1;
986 } 984
987 985 offset_attr = child.attr("offset");
988 offset_attr = child.attr("offset"); 986 if(offset_attr)
989 if(offset_attr) 987 offset = parseFloat(offset_attr.value());
990 offset = parseFloat(offset_attr.value()); 988 else
991 else 989 offset = 0;
992 offset = 0; 990
993 991 stops.push([offset, r, g, b, a]);
994 stops.push([offset, r, g, b, a]); 992 }
995 } 993 }
996 994
997 return stops; 995 return stops;
998 }; 996 };
999 997
1002 var id = n.attr('id'); 1000 var id = n.attr('id');
1003 var k; 1001 var k;
1004 var nodes = n.childNodes(); 1002 var nodes = n.childNodes();
1005 1003
1006 if (id == null) return; 1004 if (id == null) return;
1005 id = id.value();
1006
1007 var x1 = n.attr("x1"); 1007 var x1 = n.attr("x1");
1008 var y1 = n.attr("y1"); 1008 var y1 = n.attr("y1");
1009 var x2 = n.attr("x2"); 1009 var x2 = n.attr("x2");
1010 var y2 = n.attr("y2"); 1010 var y2 = n.attr("y2");
1011 var gr; 1011 var gr;
1012 var color, opacity; 1012 var color, opacity;
1013 var stops; 1013 var stops;
1014 var r,g,b; 1014 var r,g,b;
1015 1015
1016 if(x1)
1017 x1 = parseFloat(x1.value());
1018 if(x2)
1019 x2 = parseFloat(x2.value());
1020 if(y1)
1021 y1 = parseFloat(y1.value());
1022 if(y2)
1023 y2 = parseFloat(y2.value());
1024
1016 stops = _parse_stops(n); 1025 stops = _parse_stops(n);
1017 1026
1018 var href = n.attr('href'); 1027 var href = n.attr('href');
1019 if (href != null) { 1028 if(href != null) {
1020 href = href.value(); 1029 href = href.value();
1021 var hrefid = href.substring(1); 1030 var hrefid = href.substring(1);
1022 pstops = this.stop_ref[hrefid]; 1031 pstops = this.stop_ref[hrefid];
1023 stops = pstops.concat(stops); 1032 stops = pstops.concat(stops);
1024 1033
1025 var hrefgr = this.gradients[hrefid]; 1034 var hrefgr = this.gradients[hrefid];
1026 if (typeof x1 == "undefined") 1035 if(typeof x1 == "undefined")
1027 x1 = hrefgr[0]; 1036 x1 = hrefgr[0];
1028 if (typeof x2 == "undefined") 1037 if(typeof y1 == "undefined")
1038 y1 = hrefgr[1];
1039 if(typeof x2 == "undefined")
1029 x2 = hrefgr[2]; 1040 x2 = hrefgr[2];
1030 if (typeof y1 == "undefined") 1041 if(typeof y2 == "undefined")
1031 y1 = hrefgr[1];
1032 if (typeof y2 == "undefined")
1033 y2 = hrefgr[3]; 1042 y2 = hrefgr[3];
1034 sys.puts(hrefid); 1043 }
1035 sys.puts([x1, y1, x2, y2]);
1036 }
1037 id = id.value();
1038 this.stop_ref[id] = stops; 1044 this.stop_ref[id] = stops;
1039 if (x1)
1040 x1 = parseFloat(x1.value());
1041 if (x2)
1042 x2 = parseFloat(x2.value());
1043 if (y1)
1044 y1 = parseFloat(y1.value());
1045 if (y2)
1046 y2 = parseFloat(y2.value());
1047 this.gradients[id] = [x1,y1,x2,y2]; 1045 this.gradients[id] = [x1,y1,x2,y2];
1048 }; 1046 };
1049 1047
1050 loadSVG.prototype._MB_parseRadialGradient = function(root,n) { 1048 loadSVG.prototype._MB_parseRadialGradient = function(root,n) {
1051 var stops; 1049 var stops;