# HG changeset patch # User wycc # Date 1235283617 -28800 # Node ID 25a68d15e92f16c517cd1731d006c9db574a9b9f # Parent 4dfb850dee925fe423bc4357e8493df7ec202cb0 Merge the image loader back diff -r 4dfb850dee92 -r 25a68d15e92f tools/svg2code.py --- a/tools/svg2code.py Sun Feb 22 13:45:28 2009 +0800 +++ b/tools/svg2code.py Sun Feb 22 14:20:17 2009 +0800 @@ -585,6 +585,45 @@ pass pass +@check_mbname +def translate_image(image, coord_id, codefo, doc): + coord_id = translate_shape_transform(image, coord_id, codefo) + + image_id = _get_id(image) + if not image.hasAttributeNS(xlinkns, 'href'): + raise ValueError, 'image %s must has a href attribute.' % (image_id) + href = image.getAttributeNS(xlinkns, 'href') + if image.hasAttribute('x'): + x_str = image.getAttribute('x') + x = float(x_str) + else: + x = 0 + pass + if image.hasAttribute('y'): + y_str = image.getAttribute('y') + y = float(y_str) + else: + y = 0 + pass + if image.hasAttribute('width'): + width_str = image.getAttribute('width') + width = float(width_str) + else: + width = -1 + pass + if image.hasAttribute('height'): + height_str = image.getAttribute('height') + height = float(height_str) + else: + height = -1 + pass + print >> codefo, 'dnl' + print >> codefo, \ + 'ADD_IMAGE([%s], [%s], %f, %f, %f, %f, [%s])dnl' % ( + image_id, href, x, y, width, height, coord_id) + pass + + reo_func = re.compile('([a-zA-Z]+)\\([^\\)]*\\)') reo_translate = re.compile('translate\\(([-+]?[0-9]+(\\.[0-9]+)?),([-+]?[0-9]+(\\.[0-9]+)?)\\)') reo_matrix = re.compile('matrix\\(([-+]?[0-9]+(\\.[0-9]+)?),([-+]?[0-9]+(\\.[0-9]+)?),([-+]?[0-9]+(\\.[0-9]+)?),([-+]?[0-9]+(\\.[0-9]+)?),([-+]?[0-9]+(\\.[0-9]+)?),([-+]?[0-9]+(\\.[0-9]+)?)\\)') @@ -639,7 +678,8 @@ translate_rect(node, group_id, codefo, doc) elif node.localName == 'text': translate_text(node, group_id, codefo, doc) - pass + elif node.localName == 'image': + translate_image(node, group_id, codefo, doc) elif node.localName == 'textarea': translate_textarea(node, group_id, codefo, doc) pass