diff tools/svg2code.py @ 260:29acbd8a0dd0

Integrate sh_image with svg2code.py. diff -r e8a784a306d0 examples/svg2code_ex/dsc_3241.png Binary file examples/svg2code_ex/dsc_3241.png has changed diff -r e8a784a306d0 examples/svg2code_ex/dsc_3241.png Binary file examples/svg2code_ex/dsc_3241.png has changed
author Thinker K.F. Li <thinker@branda.to>
date Fri, 23 Jan 2009 23:00:23 +0800
parents 50d253d0fcba
children c96f38ad4bb6
line wrap: on
line diff
--- a/tools/svg2code.py	Thu Jan 22 18:10:47 2009 +0800
+++ b/tools/svg2code.py	Fri Jan 23 23:00:23 2009 +0800
@@ -371,6 +371,8 @@
 
 @check_mbname
 def translate_text(text, coord_id, codefo, doc):
+    coord_id = translate_shape_transform(text, coord_id, codefo)
+    
     translate_font_style(text, codefo)
 
     txt_strs = []
@@ -397,38 +399,40 @@
 
 @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.hasAttribute('href'):
+    if not image.hasAttributeNS(xlinkns, 'href'):
         raise ValueError, 'image %s must has a href attribute.' % (image_id)
-    href = image.getAttribute('href')
+    href = image.getAttributeNS(xlinkns, 'href')
     if image.hasAttribute('x'):
         x_str = image.getAttribute('x')
-        x = int(x_str)
+        x = float(x_str)
     else:
         x = 0
         pass
     if image.hasAttribute('y'):
         y_str = image.getAttribute('y')
-        y = int(y_str)
+        y = float(y_str)
     else:
         y = 0
         pass
     if image.hasAttribute('width'):
         width_str = image.getAttribute('width')
-        width = int(width_str)
+        width = float(width_str)
     else:
         width = -1
         pass
     if image.hasAttribute('height'):
         height_str = image.getAttribute('height')
-        height = int(height_str)
+        height = float(height_str)
     else:
         height = -1
         pass
     print >> codefo, 'dnl'
     print >> codefo, \
-        'ADD_IMAGE([%s], [%s], %f, %f, %f, %f)dnl' % (
-        image_id, href, x, y, width, height)
+        '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]+)\\([^\\)]*\\)')