comparison tools/svg2code.py @ 63:f4b792afa74e

m4 translator
author Thinker K.F. Li <thinker@branda.to>
date Tue, 12 Aug 2008 14:21:09 +0800
parents 7d976d925431
children c668c5c3ceae
comparison
equal deleted inserted replaced
62:7d976d925431 63:f4b792afa74e
24 else: 24 else:
25 raise ValueError, '\'%s\' is invalid color value.' % (color) 25 raise ValueError, '\'%s\' is invalid color value.' % (color)
26 26
27 opacity = style_map['stop-opacity'] 27 opacity = style_map['stop-opacity']
28 offset = node.getAttribute('offset') 28 offset = node.getAttribute('offset')
29 print >> codefo, 'ADD_STOP([%s], [%f, %f, %f, %f], [%f])dnl' % ( 29 print >> codefo, '[COLOR_STOP([%s], %f, %f, %f, %f, %f)],' % (
30 parent_id, r, g, b, float(opacity), float(offset)) 30 parent_id, r, g, b, float(opacity), float(offset))
31 pass 31 pass
32 pass 32 pass
33 pass 33 pass
34 34
40 x2 = float(linear.getAttribute('x2')) 40 x2 = float(linear.getAttribute('x2'))
41 y2 = float(linear.getAttribute('y2')) 41 y2 = float(linear.getAttribute('y2'))
42 else: 42 else:
43 x1 = y1 = x2 = y2 = 0 43 x1 = y1 = x2 = y2 = 0
44 pass 44 pass
45 print >> codefo, 'ADD_LINEAR_PAINT([%s], [%f, %f, %f, %f])dnl' % ( 45 print >> codefo, 'ADD_LINEAR_PAINT([%s], %f, %f, %f, %f, [' % (
46 linear_id, x1, y1, x2, y2) 46 linear_id, x1, y1, x2, y2)
47 translate_stops(linear, codefo, linear_id) 47 translate_stops(linear, codefo, linear_id)
48 print >> codefo, '])dnl'
48 49
49 href = linear.getAttributeNS(xlinkns, 'href').strip() 50 href = linear.getAttributeNS(xlinkns, 'href').strip()
50 if href and href[0] == '#': 51 if href and href[0] == '#':
51 print >> codefo, 'REF_STOPS([%s], [%s])dnl' % (linear_id, href[1:]) 52 print >> codefo, 'REF_STOPS([%s], [%s])dnl' % (linear_id, href[1:])
52 pass 53 pass
63 try: 64 try:
64 r = float(radial.getAttribute('r')) 65 r = float(radial.getAttribute('r'))
65 except: 66 except:
66 r = 0.5 67 r = 0.5
67 pass 68 pass
68 print >> codefo, 'ADD_RADIAL_PAINT([%s], [%f, %f], %f)dnl' % ( 69 print >> codefo, 'ADD_RADIAL_PAINT([%s], %f, %f, %f, [' % (
69 radial_id, cx, cy, r) 70 radial_id, cx, cy, r)
70 translate_stops(radial, codefo, radial_id) 71 translate_stops(radial, codefo, radial_id)
72 print >>codefo, '])dnl'
71 73
72 href = radial.getAttributeNS(xlinkns, 'href').strip() 74 href = radial.getAttributeNS(xlinkns, 'href').strip()
73 if href[0] == '#': 75 if href[0] == '#':
74 print >> codefo, 'REF_STOPS([%s], [%s])dnl' % (radial_id, href[1:]) 76 print >> codefo, 'REF_STOPS([%s], [%s])dnl' % (radial_id, href[1:])
75 pass 77 pass