Mercurial > MadButterfly
annotate nodejs/svg.js @ 706:fdd68e69c59f
Parse path tag for SVG
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 13 Aug 2010 17:20:17 +0800 |
parents | d950487bd9f9 |
children | ac9c20db953e |
rev | line source |
---|---|
624 | 1 var libxml = require('libxmljs'); |
2 var sys=require('sys'); | |
3 var mbfly = require("mbfly"); | |
4 var mb_rt = new mbfly.mb_rt(":0.0", 720,480); | |
646 | 5 var ldr = mbfly.img_ldr_new("."); |
624 | 6 |
7 function MB_loadSVG(mb_rt,root,filename) { | |
8 var doc = libxml.parseXmlFile(filename); | |
9 var nodes = doc.root().childNodes(); | |
10 var coord = mb_rt.coord_new(root); | |
11 var k; | |
12 | |
13 for(k in nodes) { | |
14 var n = nodes[k].name(); | |
15 if (n == "defs") { | |
16 _MB_parseDefs(root,nodes[k]); | |
17 } else if (n == "g") { | |
18 _MB_parseGroup(root,'root_coord',nodes[k]); | |
19 } | |
20 } | |
21 } | |
22 | |
23 function getInteger(n,name) | |
24 { | |
25 if (n == null) return 0; | |
26 var a = n.attr(name); | |
27 if (a==null) return 0; | |
28 return parseInt(a.value()); | |
29 } | |
631 | 30 function parsePointSize(s) |
31 { | |
32 var fs=0; | |
33 var i; | |
624 | 34 |
631 | 35 for(i=0;i<s.length;i++) { |
36 if (s[i]<'0' || s[i] > '9') break; | |
37 fs = fs*10 + (s[i]-'0'); | |
38 } | |
39 return fs; | |
40 | |
41 } | |
42 | |
43 | |
44 function parseColor(c) | |
45 { | |
46 if (c[0] == '#') { | |
47 return parseInt(c.substring(1,3),16)<<16 | parseInt(c.substring(3,5),16)<<8 | parseInt(c.substring(5,7),16); | |
48 } | |
49 } | |
50 function parseTextStyle(style,n) | |
624 | 51 { |
625
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
52 var attr; |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
53 if (n) { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
54 attr = n.attr('style'); |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
55 } else { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
56 attr = null; |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
57 } |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
58 if (attr == null) { |
631 | 59 return; |
625
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
60 } |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
61 var f = attr.value().split(';'); |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
62 |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
63 for(i in f) { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
64 var kv = f[i].split(':'); |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
65 if (kv[0] == 'font-size') { |
631 | 66 style.fs = parsePointSize(kv[1]); |
625
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
67 } else if (kv[0] == "font-style") { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
68 } else if (kv[0] == "font-weight") { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
69 } else if (kv[0] == "fill") { |
631 | 70 style.color = parseColor(kv[1]); |
625
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
71 } else if (kv[0] == "fill-opacity") { |
703
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
72 } else if (kv[0] == "stroke-opacity") { |
625
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
73 } else if (kv[0] == "stroke") { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
74 } else if (kv[0] == "stroke-width") { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
75 } else if (kv[0] == "stroke-linecap") { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
76 } else if (kv[0] == "stroke-linejoin") { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
77 } else if (kv[0] == "stroke-lineopacity") { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
78 } else if (kv[0] == "font-family") { |
631 | 79 style.family = kv[1]; |
625
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
80 } else if (kv[0] == "font-stretch") { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
81 } else if (kv[0] == "font-variant") { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
82 } else if (kv[0] == "text-anchor") { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
83 } else if (kv[0] == "text-align") { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
84 } else if (kv[0] == "writing-mode") { |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
85 } else if (kv[0] == "line-height") { |
632 | 86 } else { |
625
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
87 sys.puts("Unknown style: "+kv[0]); |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
88 } |
9f2080b68f8e
Add the text style parser. This can not handle the recursive tspan yet.
wycc
parents:
624
diff
changeset
|
89 } |
624 | 90 } |
91 | |
631 | 92 function _MB_parseTSpan(coord, n,style) |
624 | 93 { |
94 var x = getInteger(n,'x'); | |
95 var y = getInteger(n,'y'); | |
96 var tcoord = mb_rt.coord_new(coord); | |
97 var nodes = n.childNodes(); | |
98 var k; | |
99 | |
100 sys.puts(n.text()); | |
101 var obj = mb_rt.stext_new(n.text(),x,y); | |
631 | 102 parseTextStyle(style,n); |
103 style.paint = mb_rt.paint_color_new(1,1,1,1); | |
104 style.face=mb_rt.font_face_query(style.family, 2, 100); | |
105 obj.set_style([[20,style.face,style.fs]]); | |
106 style.paint.fill(obj); | |
624 | 107 tcoord.add_shape(obj); |
108 for(k in nodes) { | |
109 var name = nodes[k].name(); | |
110 if (name == "tspan") { | |
111 _MB_parseTSpan(tcoord,nodes[k]); | |
112 } else { | |
113 } | |
114 } | |
115 } | |
116 | |
706 | 117 function _prepare_paint_color(color, alpha) { |
118 var paint; | |
119 | |
120 if (color[0]=='#') { | |
121 var r,g,b; | |
122 r = parseInt(color.substring(1,3),16)/256; | |
123 g = parseInt(color.substring(3,5),16)/256; | |
124 b = parseInt(color.substring(5,7),16)/256; | |
125 paint = mb_rt.paint_color_new(r, g, b, alpha); | |
126 } else { | |
127 paint = mb_rt.paint_color_new(0,0,0,1); | |
128 } | |
129 return paint; | |
130 } | |
131 | |
132 function _MB_parsePath(coord,id, n) | |
133 { | |
134 var d = n.attr('d').value(); | |
135 var style = n.attr('style'); | |
136 var path = mb_rt.path_new(d); | |
137 var paint; | |
138 | |
139 if (style==null) { | |
140 paint = mb_rt.paint_color_new(0,0,0,0.1); | |
141 paint.stroke(path); | |
142 } else { | |
143 var items = style.value().split(';'); | |
144 var fill_alpha = 1; | |
145 var stroke_alpha = 1; | |
146 var fill_color; | |
147 var stroke_color; | |
148 var alpha; | |
149 | |
150 for(i in items) { | |
151 sys.puts(items[i]); | |
152 var f = items[i].split(':'); | |
153 if (f[0] == 'opacity') { | |
154 alpha = f[1]; | |
155 } else if (f[0] == 'fill') { | |
156 if(f[1] != "none") | |
157 fill_color = f[1]; | |
158 } else if (f[0] == 'fill-opacity') { | |
159 fill_alpha = parseFloat(f[1]); | |
160 } else if (f[0] == 'stroke') { | |
161 if(f[1] != "none") | |
162 stroke_color = f[1]; | |
163 } else if (f[0] == 'stroke-width') { | |
164 path.stroke_width = parseFloat(f[1]); | |
165 } else if (f[0] == 'stroke-opacity') { | |
166 stroke_alpha = parseFloat(f[1]); | |
167 } | |
168 } | |
169 | |
170 if(fill_color) { | |
171 paint = _prepare_paint_color(fill_color, fill_alpha); | |
172 paint.fill(path); | |
173 } | |
174 if(stroke_color) { | |
175 paint = _prepare_paint_color(stroke_color, stroke_alpha); | |
176 paint.stroke(path); | |
177 } | |
178 | |
179 } | |
180 coord.add_shape(path); | |
181 } | |
182 | |
624 | 183 function _MB_parseText(coord,id, n) |
184 { | |
185 var x = getInteger(n,'x'); | |
186 var y = getInteger(n,'y'); | |
187 var tcoord = mb_rt.coord_new(coord); | |
631 | 188 var style = new Object(); |
189 style.fs = 20; | |
190 style.family = 'courier'; | |
191 parseTextStyle(style,n); | |
624 | 192 var nodes = n.childNodes(); |
193 var k; | |
194 for(k in nodes) { | |
195 var n = nodes[k].name(); | |
196 if (n == "tspan") { | |
631 | 197 _MB_parseTSpan(tcoord,nodes[k],style); |
624 | 198 } else { |
199 } | |
200 } | |
201 | |
202 | |
203 } | |
204 | |
205 function parseTransform(coord, s) | |
206 { | |
207 var off = s.indexOf('translate'); | |
208 if (off != -1) { | |
209 var ss = s.substring(off+9); | |
210 for(i=0;i<ss.length;i++) { | |
211 if (ss[i] == '(') break; | |
212 } | |
213 ss = ss.substring(i+1); | |
214 for(i=0;i<ss.length;i++) { | |
215 if (ss[i] == ')') { | |
216 ss = ss.substring(0,i); | |
217 break; | |
218 } | |
219 } | |
220 var f = ss.split(','); | |
221 var x,y; | |
706 | 222 x = parseFloat(f[0]); |
223 y = parseFloat(f[1]); | |
224 coord[0] = 1; | |
225 coord[1] = 0; | |
226 coord[2] = x; | |
227 coord[3] = 0; | |
228 coord[4] = 1; | |
624 | 229 coord[5] = y; |
230 } | |
231 off = s.indexOf('matrix'); | |
232 if (off != -1) { | |
703
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
233 var end = s.indexOf(')'); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
234 var m = s.substring(7,end); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
235 var fields = m.split(','); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
236 coord[0] = parseFloat(fields[0]); |
706 | 237 coord[1] = parseFloat(fields[2]); |
703
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
238 coord[2] = parseFloat(fields[4]); |
706 | 239 coord[3] = parseFloat(fields[1]); |
703
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
240 coord[4] = parseFloat(fields[3]); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
241 coord[5] = parseFloat(fields[5]); |
624 | 242 } |
243 } | |
244 | |
245 function _MB_parseRect(coord, id, n) | |
246 { | |
703
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
247 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
|
248 var y = getInteger(n,'y'); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
249 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
|
250 var h = getInteger(n,'height'); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
251 var paint; |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
252 |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
253 var style = n.attr('style'); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
254 |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
255 if (style==null) { |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
256 paint = mb_rt.paint_color_new(0,0,0,0.1); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
257 } else { |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
258 var items = style.value().split(';'); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
259 var fill = ''; |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
260 var alpha; |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
261 for(i in items) { |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
262 sys.puts(items[i]); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
263 var f = items[i].split(':'); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
264 if (f[0] == 'opacity') { |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
265 alpha = f[1]; |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
266 } else if (f[0] == 'fill') { |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
267 fill = f[1]; |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
268 } else if (f[0] == 'fill-opacity') { |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
269 } else if (f[0] == 'stroke') { |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
270 } else if (f[0] == 'stroken-width') { |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
271 } else if (f[0] == 'stroke-opacity') { |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
272 } |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
273 } |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
274 sys.puts("fill="+fill); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
275 if (fill[0]=='#') { |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
276 var r,g,b; |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
277 r = parseInt(fill.substring(1,3),16)/256; |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
278 g = parseInt(fill.substring(3,5),16)/256; |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
279 b = parseInt(fill.substring(5,7),16)/256; |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
280 sys.puts("r="+r+" g="+g+" b="+b+" a="+alpha); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
281 |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
282 paint = mb_rt.paint_color_new(r,g,b,parseFloat(alpha)); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
283 } else { |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
284 paint = mb_rt.paint_color_new(0,0,0,1); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
285 } |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
286 } |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
287 var rect = mb_rt.rect_new(x,y,w,h,10, 10); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
288 sys.puts("rect x="+x+" y="+y+" w="+w+" h="+h); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
289 paint.fill(rect); |
3457519e3b9c
Add rect and matrix support. The test.svg can be rendered almost correctly now.
wycc
parents:
647
diff
changeset
|
290 coord.add_shape(rect); |
624 | 291 } |
292 | |
293 function _MB_parseGroup(root, group_id, n) | |
294 { | |
295 var k; | |
296 var nodes = n.childNodes(); | |
297 var coord = mb_rt.coord_new(root); | |
298 // Parse the transform and style here | |
299 var trans = n.attr('transform'); | |
300 if (trans!=null) { | |
301 parseTransform(coord, trans.value()); | |
302 } | |
303 | |
304 for(k in nodes) { | |
305 var n = nodes[k].name(); | |
306 var attr = nodes[k].attr('id'); | |
307 var id; | |
308 if (attr) { | |
309 id = attr.value(); | |
310 } | |
311 if (n == "g") { | |
312 _MB_parseGroup(coord, id, nodes[k]); | |
706 | 313 } else if (n == "path") { |
314 _MB_parsePath(coord, id, nodes[k]); | |
624 | 315 } else if (n == "text") { |
316 _MB_parseText(coord, id, nodes[k]); | |
317 } else if (n == "rect") { | |
318 _MB_parseRect(coord, id, nodes[k]); | |
646 | 319 } else if (n == "image") { |
320 _MB_parseImage(coord, id, nodes[k]); | |
624 | 321 } |
322 } | |
323 | |
324 } | |
325 | |
646 | 326 function _MB_parseImage(coord,id, n) |
327 { | |
328 sys.puts("---> image"); | |
329 var ref = n.attr('href').value(); | |
330 | |
331 if (ref == null) return; | |
332 sys.puts(ref); | |
647 | 333 if (ref.substr(0,7) == "file://") { |
334 ref = ref.substring(7); | |
335 } else if (ref.substr(0,5)=="file:") { | |
336 ref = ref.substring(5); | |
337 } else { | |
646 | 338 return; |
339 } | |
340 sys.puts("Load image "+ref); | |
341 var w; | |
342 var h; | |
343 var x,y; | |
344 | |
345 w = n.attr("width"); | |
346 if (w == null) return; | |
347 w = parseInt(w.value()); | |
348 h = n.attr("height"); | |
349 if (h == null) return; | |
350 h = parseInt(h.value()); | |
351 x = n.attr("x"); | |
352 if (x == null) return; | |
353 x = parseInt(x.value()); | |
354 y = n.attr("y"); | |
355 if (y == null) return; | |
356 y = parseInt(y.value()); | |
357 sys.puts("x="+x+",y="+y+",w="+w+",h="+h); | |
358 var img = mb_rt.image_new(x,y,w,h); | |
359 var img_data = ldr.load(ref); | |
360 sys.puts(img_data); | |
361 var paint = mb_rt.paint_image_new(img_data); | |
362 paint.fill(img); | |
363 coord.add_shape(img); | |
364 } | |
624 | 365 |
366 function _MB_parseDefs(root,n) | |
367 { | |
368 var k; | |
369 var nodes = n.childNodes(); | |
370 | |
371 for(k in nodes) { | |
372 var name = nodes[k].name(); | |
373 if (name == "linearGradient") { | |
374 //_MB_parseLinearGradient(root,nodes[k]); | |
375 } | |
376 } | |
377 } | |
378 | |
379 | |
380 MB_loadSVG(mb_rt,mb_rt.root,"test.svg"); | |
381 mb_rt.redraw_all(); | |
704
d950487bd9f9
Flush mb_rt, immediately, after redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
703
diff
changeset
|
382 mb_rt.flush(); |