Mercurial > MadButterfly
annotate nodejs/svg.js @ 785:b6d9c42019d1
Refactor color parsing and fix bug of parsing path
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 31 Aug 2010 00:49:35 +0800 |
parents | 37a1bd3e3ce1 |
children | 0899dcac441c |
rev | line source |
---|---|
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
1 // -*- indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*- |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
2 // vim: sw=4:ts=8:sts=4 |
624 | 3 var libxml = require('libxmljs'); |
4 var sys=require('sys'); | |
5 var mbfly = require("mbfly"); | |
646 | 6 var ldr = mbfly.img_ldr_new("."); |
714 | 7 |
624 | 8 |
713 | 9 var _std_colors = { |
10 "white": [1, 1, 1], | |
11 "black": [0, 0, 0], | |
12 "red": [1, 0, 0] | |
13 }; | |
14 | |
714 | 15 exports.loadSVG=function(mb_rt,root,filename) { |
718
0cd59ce76e67
Refactor loadSVG as a class
Thinker K.F. Li <thinker@branda.to>
parents:
717
diff
changeset
|
16 return new loadSVG(mb_rt, root, filename); |
0cd59ce76e67
Refactor loadSVG as a class
Thinker K.F. Li <thinker@branda.to>
parents:
717
diff
changeset
|
17 }; |
0cd59ce76e67
Refactor loadSVG as a class
Thinker K.F. Li <thinker@branda.to>
parents:
717
diff
changeset
|
18 |
784
37a1bd3e3ce1
mbapp accept arguments for display, width and height
Thinker K.F. Li <thinker@codemud.net>
parents:
783
diff
changeset
|
19 |
718
0cd59ce76e67
Refactor loadSVG as a class
Thinker K.F. Li <thinker@branda.to>
parents:
717
diff
changeset
|
20 function loadSVG(mb_rt, root, filename) { |
624 | 21 var doc = libxml.parseXmlFile(filename); |
22 var nodes = doc.root().childNodes(); | |
23 var coord = mb_rt.coord_new(root); | |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
24 var k; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
25 var accu=[1,0,0,0,1,0]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
26 this.mb_rt = mb_rt; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
27 this.stop_ref={}; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
28 this.gradients={}; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
29 root.center=new Object(); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
30 root.center.x = 10000; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
31 root.center.y = 10000; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
32 |
624 | 33 for(k in nodes) { |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
34 var n = nodes[k].name(); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
35 if (n == "defs") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
36 this.parseDefs(root,nodes[k]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
37 } else if (n == "g") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
38 this.parseGroup(accu,root,'root_coord',nodes[k]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
39 } |
624 | 40 } |
41 } | |
42 | |
719
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
43 function make_mbnames(mb_rt, n, obj) { |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
44 var mbname; |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
45 var name; |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
46 |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
47 if(!mb_rt.mbnames) |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
48 mb_rt.mbnames = {}; |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
49 |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
50 mbname = n.attr("mbname"); |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
51 if(mbname) { |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
52 name = mbname.value(); |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
53 mb_rt.mbnames[name] = obj; |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
54 } |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
55 } |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
56 |
624 | 57 function getInteger(n,name) |
58 { | |
59 if (n == null) return 0; | |
60 var a = n.attr(name); | |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
61 if (a==null) return 0; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
62 return parseInt(a.value()); |
624 | 63 } |
719
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
64 |
631 | 65 function parsePointSize(s) |
66 { | |
67 var fs=0; | |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
68 var i; |
624 | 69 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
70 for(i=0;i<s.length;i++) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
71 if (s[i]<'0' || s[i] > '9') break; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
72 fs = fs*10 + (s[i]-'0'); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
73 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
74 return fs; |
631 | 75 |
76 } | |
77 | |
78 function parseColor(c) | |
79 { | |
80 if (c[0] == '#') { | |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
81 return parseInt(c.substring(1,3),16)<<16 | parseInt(c.substring(3,5),16)<<8 | parseInt(c.substring(5,7),16); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
82 } |
631 | 83 } |
719
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
84 |
631 | 85 function parseTextStyle(style,n) |
624 | 86 { |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
87 var attr; |
625
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
88 if (n) { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
89 attr = n.attr('style'); |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
90 } else { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
91 attr = null; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
92 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
93 if (attr == null) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
94 return; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
95 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
96 var f = attr.value().split(';'); |
625
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
97 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
98 for(i in f) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
99 var kv = f[i].split(':'); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
100 if (kv[0] == 'font-size') { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
101 style.fs = parsePointSize(kv[1]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
102 } else if (kv[0] == "font-style") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
103 } else if (kv[0] == "font-weight") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
104 } else if (kv[0] == "fill") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
105 style.color = parseColor(kv[1]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
106 } else if (kv[0] == "fill-opacity") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
107 } else if (kv[0] == "stroke-opacity") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
108 } else if (kv[0] == "stroke") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
109 } else if (kv[0] == "stroke-width") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
110 } else if (kv[0] == "stroke-linecap") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
111 } else if (kv[0] == "stroke-linejoin") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
112 } else if (kv[0] == "stroke-lineopacity") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
113 } else if (kv[0] == "font-family") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
114 style.family = kv[1]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
115 } else if (kv[0] == "font-stretch") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
116 } else if (kv[0] == "font-variant") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
117 } else if (kv[0] == "text-anchor") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
118 } else if (kv[0] == "text-align") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
119 } else if (kv[0] == "writing-mode") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
120 } else if (kv[0] == "line-height") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
121 } else { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
122 sys.puts("Unknown style: "+kv[0]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
123 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
124 } |
624 | 125 } |
732
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
720
diff
changeset
|
126 function tspan_set_text(text) |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
720
diff
changeset
|
127 { |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
128 this.text.set_text(text); |
732
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
720
diff
changeset
|
129 } |
624 | 130 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
131 loadSVG.prototype.parseTSpan = function(coord, n,style) { |
624 | 132 var x = getInteger(n,'x'); |
133 var y = getInteger(n,'y'); | |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
134 var tcoord = this.mb_rt.coord_new(coord); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
135 var nodes = n.childNodes(); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
136 var k; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
137 |
714 | 138 var obj = this.mb_rt.stext_new(n.text(),x,y); |
631 | 139 parseTextStyle(style,n); |
714 | 140 style.paint = this.mb_rt.paint_color_new(1,1,1,1); |
141 style.face=this.mb_rt.font_face_query(style.family, 2, 100); | |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
142 obj.set_style([[20,style.face,style.fs]]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
143 style.paint.fill(obj); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
144 tcoord.add_shape(obj); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
145 for(k in nodes) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
146 var name = nodes[k].name(); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
147 if (name == "tspan") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
148 this.parseTSpan(tcoord,nodes[k]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
149 } else { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
150 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
151 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
152 tcoord.set_text=tspan_set_text; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
153 tcoord.text = obj; |
719
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
154 make_mbnames(this.mb_rt, n, tcoord); |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
155 }; |
624 | 156 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
157 loadSVG.prototype._prepare_paint_color = function(color, alpha) { |
706 | 158 var paint; |
713 | 159 var c; |
706 | 160 |
161 if (color[0]=='#') { | |
162 var r,g,b; | |
717
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
163 r = parseInt(color.substring(1,3),16)/255; |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
164 g = parseInt(color.substring(3,5),16)/255; |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
165 b = parseInt(color.substring(5,7),16)/255; |
714 | 166 paint = this.mb_rt.paint_color_new(r, g, b, alpha); |
713 | 167 } else if(_std_colors[color]) { |
168 c = _std_colors[color]; | |
714 | 169 paint = this.mb_rt.paint_color_new(c[0], c[1], c[2], alpha); |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
170 } else if (fill.substring(0,3) == 'url') { |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
171 var id = fill.substring(5,fill.length-1); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
172 var gr = this.gradients[id]; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
173 paint = this.mb_rt.paint_linear_new(gr[0],gr[1],gr[2],gr[3]); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
174 paint.set_stops(this.stop_ref[id]); |
706 | 175 } else { |
714 | 176 paint = this.mb_rt.paint_color_new(0,0,0,1); |
706 | 177 } |
178 return paint; | |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
179 }; |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
180 |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
181 function guessPathBoundingBox(coord,d) |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
182 { |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
183 return; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
184 var items = d.split(' '); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
185 var len = items.length; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
186 var pair; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
187 var i; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
188 var minx,miny; |
759 | 189 |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
190 minx = 10000; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
191 miny = 10000; |
759 | 192 |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
193 for(i=0;i<len;i++) { |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
194 var type = items[i].toLowerCase(); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
195 x = minx;y = miny; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
196 switch(type) { |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
197 case 'm': |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
198 case 'l': |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
199 case 'a': |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
200 case 'x': |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
201 pair = items[i+1].split(','); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
202 if (pair.length==2) { |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
203 x = parseFloat(pair[0]); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
204 y = parseFloat(pair[1]); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
205 i++; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
206 } else { |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
207 x = parseFloat(items[i+1]); |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
208 y = parseFloat(items[i+2]); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
209 i+=2; |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
210 } |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
211 break; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
212 case 'q': |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
213 // Implement this latter |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
214 break; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
215 case 'c': |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
216 // Implement this latter |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
217 break; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
218 case 's': |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
219 // Implement this latter |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
220 break; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
221 case 'h': |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
222 x = parseFloat(items[i+1]); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
223 break; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
224 case 'v': |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
225 y = parseFloat(items[i+1]); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
226 break; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
227 default: |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
228 continue; |
759 | 229 } |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
230 if (x < minx) minx = x; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
231 if (y < miny) miny = y; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
232 } |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
233 if (coord.center.x > minx) |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
234 coord.center.x = minx; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
235 if (coord.center.y > miny) |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
236 coord.center.y = miny; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
237 }; |
759 | 238 |
239 | |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
240 loadSVG.prototype._set_paint = function(node, tgt) { |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
241 var style = node.attr('style'); |
706 | 242 var paint; |
717
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
243 var fill_alpha = 1; |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
244 var stroke_alpha = 1; |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
245 var fill_color; |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
246 var stroke_color; |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
247 var black_paint; |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
248 var i; |
706 | 249 |
717
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
250 if(style != null) { |
706 | 251 var items = style.value().split(';'); |
252 var alpha; | |
253 | |
254 for(i in items) { | |
255 var f = items[i].split(':'); | |
256 if (f[0] == 'opacity') { | |
257 alpha = f[1]; | |
258 } else if (f[0] == 'fill') { | |
717
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
259 fill_color = f[1]; |
706 | 260 } else if (f[0] == 'fill-opacity') { |
261 fill_alpha = parseFloat(f[1]); | |
262 } else if (f[0] == 'stroke') { | |
717
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
263 stroke_color = f[1]; |
706 | 264 } else if (f[0] == 'stroke-width') { |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
265 tgt.stroke_width = parseFloat(f[1]); |
706 | 266 } else if (f[0] == 'stroke-opacity') { |
267 stroke_alpha = parseFloat(f[1]); | |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
268 } else if (f[0] == 'display') { |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
269 if(f[1] == 'none') |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
270 return; |
706 | 271 } |
272 } | |
273 | |
717
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
274 } |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
275 |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
276 if(!fill_color || !stroke_color) |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
277 black_paint = this.mb_rt.paint_color_new(0, 0, 0, 1); |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
278 |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
279 if(fill_color) { |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
280 if(fill_color != "none") { |
714 | 281 paint = this._prepare_paint_color(fill_color, fill_alpha); |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
282 paint.fill(tgt); |
706 | 283 } |
717
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
284 } else { |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
285 black_paint.fill(tgt); |
717
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
286 } |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
287 if(stroke_color) { |
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
288 if(stroke_color != "none") { |
714 | 289 paint = this._prepare_paint_color(stroke_color, stroke_alpha); |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
290 paint.stroke(tgt); |
706 | 291 } |
717
b822b1912d67
Paint with black for unspecified, not "none", fill and stroke.
Thinker K.F. Li <thinker@branda.to>
parents:
714
diff
changeset
|
292 } else { |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
293 black_paint.stroke(tgt); |
706 | 294 } |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
295 }; |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
296 |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
297 loadSVG.prototype.parsePath=function(accu, coord,id, n) |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
298 { |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
299 var d = n.attr('d').value(); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
300 var style = n.attr('style'); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
301 var path = this.mb_rt.path_new(d); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
302 |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
303 guessPathBoundingBox(coord,d); |
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
304 this._set_paint(n, path); |
706 | 305 coord.add_shape(path); |
719
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
306 |
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
307 make_mbnames(this.mb_rt, n, path); |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
308 }; |
706 | 309 |
776
77b561bb7929
Implement new algorithm to calculate the origin of the SVG elemnts so that we can implement object resize without changing the position of the object.
wycc
parents:
759
diff
changeset
|
310 loadSVG.prototype.parseText=function(accu,coord,id, n) |
624 | 311 { |
312 var x = getInteger(n,'x'); | |
313 var y = getInteger(n,'y'); | |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
314 var tcoord = this.mb_rt.coord_new(coord); |
631 | 315 var style = new Object(); |
759 | 316 |
776
77b561bb7929
Implement new algorithm to calculate the origin of the SVG elemnts so that we can implement object resize without changing the position of the object.
wycc
parents:
759
diff
changeset
|
317 if (n.attr('x')) { |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
318 var nx = coord[0]*x+coord[1]*y+coord[2]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
319 if (coord.center.x > nx) |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
320 coord.center.x = nx; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
321 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
322 if (n.attr('y')) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
323 var ny = coord[3]*x+coord[4]*y+coord[5]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
324 if (coord.center.y > ny) |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
325 coord.center.y = ny; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
326 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
327 style.fs = 20; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
328 style.family = 'courier'; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
329 parseTextStyle(style,n); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
330 var nodes = n.childNodes(); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
331 var k; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
332 for(k in nodes) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
333 var c= nodes[k].name(); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
334 if (c == "tspan") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
335 this.parseTSpan(tcoord,nodes[k],style); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
336 } else { |
776
77b561bb7929
Implement new algorithm to calculate the origin of the SVG elemnts so that we can implement object resize without changing the position of the object.
wycc
parents:
759
diff
changeset
|
337 } |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
338 } |
624 | 339 |
719
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
340 make_mbnames(this.mb_rt, n, tcoord); |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
341 }; |
624 | 342 |
759 | 343 |
344 function multiply(s,d) { | |
345 var m=[]; | |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
346 m[0] = s[0]*d[0]+s[1]*d[3]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
347 m[1] = s[0]*d[1]+s[1]*d[4]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
348 m[2] = s[0]*d[2]+s[1]*d[5]+s[2]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
349 m[3] = s[3]*d[0]+s[4]*d[3]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
350 m[4] = s[3]*d[1]+s[4]*d[4]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
351 m[5] = s[3]*d[2]+s[4]*d[5]+s[5]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
352 s[0] = m[0]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
353 s[1] = m[1]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
354 s[2] = m[2]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
355 s[3] = m[3]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
356 s[4] = m[4]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
357 s[5] = m[5]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
358 }; |
759 | 359 |
624 | 360 function parseTransform(coord, s) |
361 { | |
362 var off = s.indexOf('translate'); | |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
363 if (off != -1) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
364 var ss = s.substring(off+9); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
365 for(i=0;i<ss.length;i++) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
366 if (ss[i] == '(') break; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
367 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
368 ss = ss.substring(i+1); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
369 for(i=0;i<ss.length;i++) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
370 if (ss[i] == ')') { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
371 ss = ss.substring(0,i); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
372 break; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
373 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
374 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
375 var f = ss.split(','); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
376 var x,y; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
377 x = parseFloat(f[0]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
378 y = parseFloat(f[1]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
379 coord[2] += x; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
380 coord[5] += y; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
381 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
382 off = s.indexOf('matrix'); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
383 if (off != -1) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
384 var end = s.indexOf(')'); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
385 var m = s.substring(7,end); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
386 var fields = m.split(','); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
387 var newm=[]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
388 newm[0] = parseFloat(fields[0]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
389 newm[1] = parseFloat(fields[2]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
390 newm[2] = parseFloat(fields[4]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
391 newm[3] = parseFloat(fields[1]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
392 newm[4] = parseFloat(fields[3]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
393 newm[5] = parseFloat(fields[5]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
394 multiply(coord,newm); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
395 } |
624 | 396 } |
397 | |
759 | 398 loadSVG.prototype.parseRect=function(accu_matrix,coord, id, n) |
624 | 399 { |
703
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
400 var x = getInteger(n,'x'); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
401 var y = getInteger(n,'y'); |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
402 var rx,ry; |
703
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
403 var w = getInteger(n,'width'); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
404 var h = getInteger(n,'height'); |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
405 var trans = n.attr('transform'); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
406 var paint; |
776
77b561bb7929
Implement new algorithm to calculate the origin of the SVG elemnts so that we can implement object resize without changing the position of the object.
wycc
parents:
759
diff
changeset
|
407 var tcoord = this.mb_rt.coord_new(coord); |
703
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
408 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
409 var style = n.attr('style'); |
703
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
410 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
411 if (trans) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
412 parseTransform(tcoord,trans.value()); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
413 //var m = [1,0,0,0,1,0]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
414 //multiply(m,tcoord); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
415 rx = tcoord[0]*x+tcoord[1]*y+tcoord[2]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
416 ry = tcoord[3]*x+tcoord[4]*y+tcoord[5]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
417 } |
759 | 418 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
419 if (coord.center.x > rx) |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
420 coord.center.x = rx; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
421 if (coord.center.y > ry) |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
422 coord.center.y = ry; |
759 | 423 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
424 var rect = this.mb_rt.rect_new(x,y,w,h,10, 10); |
785
b6d9c42019d1
Refactor color parsing and fix bug of parsing path
Thinker K.F. Li <thinker@codemud.net>
parents:
784
diff
changeset
|
425 this._set_paint(n, rect); |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
426 tcoord.add_shape(rect); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
427 }; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
428 |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
429 // When we parse a group, we need to calculate the origin of the group |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
430 // so that we can resize the group without changing its origin point. |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
431 // This must be done recursively. For text/rect/image, we can get its |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
432 // origin point directly by using the (x,y) and apply their |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
433 // transformation matrix. For group, we need to send the acculumated |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
434 // matrix so that each group can get their origin correctly. |
776
77b561bb7929
Implement new algorithm to calculate the origin of the SVG elemnts so that we can implement object resize without changing the position of the object.
wycc
parents:
759
diff
changeset
|
435 // |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
436 // Each element must be responsible to calculate its absolute origin |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
437 // point and update the origin of its parent. |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
438 |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
439 loadSVG.prototype.parseGroup=function(accu_matrix,root, group_id, n) { |
624 | 440 var k; |
441 var nodes = n.childNodes(); | |
714 | 442 var coord = this.mb_rt.coord_new(root); |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
443 // Parse the transform and style here |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
444 var trans = n.attr('transform'); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
445 var accu=[1,0,0,0,1,0]; |
759 | 446 coord.center= new Object(); |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
447 coord.center.x = 10000; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
448 coord.center.y = 10000; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
449 if (trans!=null) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
450 parseTransform(coord, trans.value()); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
451 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
452 multiply(accu,accu_matrix); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
453 multiply(accu,coord); |
624 | 454 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
455 for(k in nodes) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
456 var c = nodes[k].name(); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
457 var attr = nodes[k].attr('id'); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
458 var id; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
459 if (attr) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
460 id = attr.value(); |
624 | 461 } |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
462 if (c == "g") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
463 this.parseGroup(accu,coord, id, nodes[k]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
464 } else if (c == "path") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
465 this.parsePath(accu,coord, id, nodes[k]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
466 } else if (c == "text") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
467 this.parseText(accu,coord, id, nodes[k]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
468 } else if (c == "rect") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
469 this.parseRect(accu_matrix,coord, id, nodes[k]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
470 } else if (c == "image") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
471 this.parseImage(accu_matrix,coord, id, nodes[k]); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
472 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
473 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
474 if (root.center.x > coord.center.x) |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
475 root.center.x = coord.center.x; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
476 if (root.center.y > coord.center.y) |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
477 root.center.y = coord.center.y; |
719
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
478 make_mbnames(this.mb_rt, n, coord); |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
479 }; |
624 | 480 |
776
77b561bb7929
Implement new algorithm to calculate the origin of the SVG elemnts so that we can implement object resize without changing the position of the object.
wycc
parents:
759
diff
changeset
|
481 loadSVG.prototype.parseImage=function(accu,coord,id, n) |
646 | 482 { |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
483 var ref = n.attr('href').value(); |
776
77b561bb7929
Implement new algorithm to calculate the origin of the SVG elemnts so that we can implement object resize without changing the position of the object.
wycc
parents:
759
diff
changeset
|
484 var tcoord = this.mb_rt.coord_new(coord); |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
485 var trans = n.attr('transform'); |
646 | 486 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
487 if (ref == null) return; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
488 if (ref.substr(0,7) == "file://") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
489 ref = ref.substring(7); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
490 } else if (ref.substr(0,5)=="file:") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
491 ref = ref.substring(5); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
492 } else { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
493 return; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
494 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
495 var w; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
496 var h; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
497 var x,y,nx,ny; |
776
77b561bb7929
Implement new algorithm to calculate the origin of the SVG elemnts so that we can implement object resize without changing the position of the object.
wycc
parents:
759
diff
changeset
|
498 coord.center= new Object(); |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
499 coord.center.x = 10000; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
500 coord.center.y = 10000; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
501 if (trans!=null) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
502 parseTransform(coord, trans.value()); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
503 } |
646 | 504 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
505 w = n.attr("width"); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
506 if (w == null) return; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
507 w = parseFloat(w.value()); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
508 h = n.attr("height"); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
509 if (h == null) return; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
510 h = parseFloat(h.value()); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
511 x = n.attr("x"); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
512 if (x == null) return; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
513 x = parseFloat(x.value()); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
514 y = n.attr("y"); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
515 if (y == null) return; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
516 y = parseFloat(y.value()); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
517 nx = tcoord[0]*x+tcoord[1]*y+tcoord[2]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
518 ny = tcoord[3]*x+tcoord[4]*y+tcoord[5]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
519 if (coord.center.x > nx) |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
520 coord.center.x = nx; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
521 if (coord.center.y > ny) |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
522 coord.center.y = ny; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
523 var img = this.mb_rt.image_new(x,y,w,h); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
524 var img_data = ldr.load(ref); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
525 var paint = this.mb_rt.paint_image_new(img_data); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
526 paint.fill(img); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
527 tcoord.add_shape(img); |
719
1b6856fda760
Collect mbnames and mapping to object through mb_rt.mbnames
Thinker K.F. Li <thinker@branda.to>
parents:
718
diff
changeset
|
528 make_mbnames(this.mb_rt, n, img); |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
529 }; |
624 | 530 |
750 | 531 loadSVG.prototype._MB_parseLinearGradient=function(root,n) |
532 { | |
533 var id = n.attr('id'); | |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
534 var k; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
535 var nodes = n.childNodes(); |
750 | 536 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
537 if (id == null) return; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
538 var x1 = n.attr("x1"); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
539 var y1 = n.attr("y1"); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
540 var x2 = n.attr("x2"); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
541 var y2 = n.attr("y2"); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
542 var gr; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
543 var color, opacity; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
544 var stops; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
545 var r,g,b; |
750 | 546 stops=[]; |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
547 for(k in nodes) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
548 var ss = nodes[k]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
549 if (ss.name()=="stop") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
550 var style = ss.attr("style").value(); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
551 var items = style.split(';'); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
552 var off = parseInt(ss.attr('offset').value()); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
553 color = 'black'; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
554 opacity = 1; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
555 for (i in items) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
556 it = items[i]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
557 var f = it.split(':'); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
558 k = f[0]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
559 v = f[1]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
560 if (k == 'stop-color') { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
561 color = v.substring(1); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
562 if (v == 'white') { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
563 r = 1; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
564 g = 1; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
565 b = 1; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
566 } else if (v == 'black') { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
567 r = 0; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
568 g = 0; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
569 b = 0; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
570 } else { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
571 r = parseInt(color.substring(0,2),16)/255.0; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
572 g = parseInt(color.substring(2,4),16)/255.0; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
573 b = parseInt(color.substring(4,6),16)/255.0; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
574 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
575 } else if (k=='stop-opacity') { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
576 opacity = parseFloat(v); |
750 | 577 } |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
578 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
579 stops.push([off, r,g,b,opacity]); |
750 | 580 } |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
581 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
582 var href = n.attr('href'); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
583 if (href != null) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
584 href = href.value(); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
585 pstops = this.stop_ref[href.substring(1)]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
586 stops = pstops.concat(stops); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
587 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
588 id = id.value(); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
589 this.stop_ref[id] = stops; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
590 if (x1) |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
591 x1 = parseFloat(x1.value()); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
592 if (x2) |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
593 x2 = parseFloat(x2.value()); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
594 if (y1) |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
595 y1 = parseFloat(y1.value()); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
596 if (y2) |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
597 y2 = parseFloat(y2.value()); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
598 this.gradients[id] = [x1,y1,x2,y2]; |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
599 }; |
750 | 600 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
601 loadSVG.prototype.parseDefs=function(root,n) |
624 | 602 { |
603 var k; | |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
604 var nodes = n.childNodes(); |
624 | 605 |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
606 for(k in nodes) { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
607 var name = nodes[k].name(); |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
608 if (name == "linearGradient") { |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
609 this._MB_parseLinearGradient(root,nodes[k]); |
624 | 610 } |
783
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
611 } |
a47431293043
Re-indent ts=8 to make editor and cat seeing the same thing
Thinker K.F. Li <thinker@codemud.net>
parents:
776
diff
changeset
|
612 }; |
624 | 613 |
614 |