comparison tools/svg2code.py @ 313:5737548e922f

Fix bug that svg2code.py handle fill & stroke opacity in a wrong way.
author Thinker K.F. Li <thinker@branda.to>
date Thu, 05 Mar 2009 00:54:42 +0800
parents 25a68d15e92f
children bdf36a26e420
comparison
equal deleted inserted replaced
312:e4abe8e149de 313:5737548e922f
128 try: 128 try:
129 prop_map = node.style_map 129 prop_map = node.style_map
130 except: 130 except:
131 style_str = node.getAttribute('style') 131 style_str = node.getAttribute('style')
132 prop_map = get_style_map(style_str) 132 prop_map = get_style_map(style_str)
133 133 pass
134 try: 134
135 if node.hasAttribute('fill-opacity'):
136 opacity = float(node.getAttribute('fill-opacity'))
137 elif node.hasAttribute('opacity'):
135 opacity = float(node.getAttribute('opacity')) 138 opacity = float(node.getAttribute('opacity'))
136 except: 139 else:
137 opacity = 1.0 140 opacity = 1
138 pass 141 pass
139 142
140 try: 143 try:
141 opacity = float(prop_map['opacity']) 144 opacity = float(prop_map['opacity'])
142 except: 145 except:
158 pass 161 pass
159 else: 162 else:
160 raise ValueError, '\'%s\' is an invalid value for fill.' % (fill) 163 raise ValueError, '\'%s\' is an invalid value for fill.' % (fill)
161 pass 164 pass
162 165
163 try: 166 if node.hasAttribute('stroke-opacity'):
164 stroke_opacity = float(node.getAttribute('stroke-opacity')) 167 stroke_opacity = float(node.getAttribute('stroke-opacity'))
165 except: 168 elif node.hasAttribute('opacity'):
169 stroke_opacity = float(node.getAttribute('opacity'))
170 else:
166 stroke_opacity = 1.0 171 stroke_opacity = 1.0
167 pass 172 pass
168 173
169 if prop_map.has_key('stroke'): 174 if prop_map.has_key('stroke'):
170 stroke = prop_map['stroke'].strip() 175 stroke = prop_map['stroke'].strip()