Mercurial > MadButterfly
comparison tools/svg2code.py @ 86:7d0580f89468
Fix bug of dealing matrix().
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 22 Aug 2008 16:14:53 +0800 |
parents | 9b4a02bcaeb1 |
children | d6f9af55b0d0 |
comparison
equal
deleted
inserted
replaced
85:9b4a02bcaeb1 | 86:7d0580f89468 |
---|---|
22 color = style_map['stop-color'].strip() | 22 color = style_map['stop-color'].strip() |
23 if len(color) == 7 and color[0] == '#': | 23 if len(color) == 7 and color[0] == '#': |
24 r = float(int(color[1:3], 16)) / 255.0 | 24 r = float(int(color[1:3], 16)) / 255.0 |
25 g = float(int(color[3:5], 16)) / 255.0 | 25 g = float(int(color[3:5], 16)) / 255.0 |
26 b = float(int(color[5:7], 16)) / 255.0 | 26 b = float(int(color[5:7], 16)) / 255.0 |
27 elif color.lower() == 'white': | |
28 r, g, b = 1, 1, 1 | |
29 elif color.lower() == 'black': | |
30 r, g, b = 0, 0, 0 | |
27 else: | 31 else: |
28 mo = re_rgb.match(color) | 32 mo = re_rgb.match(color) |
29 if mo: | 33 if mo: |
30 r = float(mo.group(1)) | 34 r = float(mo.group(1)) |
31 g = float(mo.group(3)) | 35 g = float(mo.group(3)) |
32 b = float(mo.group(5)) | 36 b = float(mo.group(5)) |
33 else: | 37 else: |
34 raise ValueError, '\'%s\' is invalid color value.' % (color) | 38 raise ValueError, '\'%s\' is invalid color value.' % (color) |
35 pass | 39 pass |
36 | 40 |
37 opacity = style_map['stop-opacity'] | 41 try: |
42 opacity = style_map['stop-opacity'] | |
43 except: | |
44 opacity = 1 | |
45 pass | |
38 offset = node.getAttribute('offset') | 46 offset = node.getAttribute('offset') |
39 stops.append('[COLOR_STOP([%s], %f, %f, %f, %f, %f)]' % ( | 47 stops.append('[COLOR_STOP([%s], %f, %f, %f, %f, %f)]' % ( |
40 parent_id, r, g, b, float(opacity), float(offset))) | 48 parent_id, r, g, b, float(opacity), float(offset))) |
41 pass | 49 pass |
42 pass | 50 pass |
134 node_id, r, g, b, opacity) | 142 node_id, r, g, b, opacity) |
135 elif fill.startswith('url(') and fill.endswith(')'): | 143 elif fill.startswith('url(') and fill.endswith(')'): |
136 paint_id = fill[5:-1] | 144 paint_id = fill[5:-1] |
137 print >> codefo, 'FILL_SHAPE_WITH_PAINT([%s], [%s])dnl' % ( | 145 print >> codefo, 'FILL_SHAPE_WITH_PAINT([%s], [%s])dnl' % ( |
138 node_id, paint_id) | 146 node_id, paint_id) |
147 elif fill.lower() == 'none': | |
148 pass | |
139 else: | 149 else: |
140 raise ValueError, '\'%s\' is an invalid value for fill.' % (fill) | 150 raise ValueError, '\'%s\' is an invalid value for fill.' % (fill) |
141 pass | 151 pass |
142 | 152 |
143 try: | 153 try: |
284 transform = transform.strip() | 294 transform = transform.strip() |
285 mo = reo_func.match(transform) | 295 mo = reo_func.match(transform) |
286 if not mo: | 296 if not mo: |
287 return | 297 return |
288 name = mo.group(1) | 298 name = mo.group(1) |
289 print name | |
290 if name == 'translate': | 299 if name == 'translate': |
291 mo = reo_translate.match(transform) | 300 mo = reo_translate.match(transform) |
292 if mo: | 301 if mo: |
293 x = float(mo.group(1)) | 302 x = float(mo.group(1)) |
294 y = float(mo.group(3)) | 303 y = float(mo.group(3)) |