3
# ./svg_levels.py >svg_levels.lua
7
from lxml.cssselect import CSSSelector
9
print '-- autogenerated by svg_levels.py\n\nsvg_objects = {'
11
ns = {'svg': 'http://www.w3.org/2000/svg',
12
'ink': 'http://www.inkscape.org/namespaces/inkscape'}
16
for svg in glob.glob('data/*.svg'):
18
basefile = os.path.basename(svg).split('.')[0]
19
print '%s = {' % basefile
21
sel = CSSSelector('svg|rect[ink|label="displace"]', ns)
23
x, y = float(e.get('x')), float(e.get('y'))
24
w, h = float(e.get('width')), float(e.get('height'))
29
width = %f, height = %f
33
sel = CSSSelector('svg|rect[ink|label="maybedisplace"]', ns)
35
x, y = float(e.get('x')), float(e.get('y'))
36
w, h = float(e.get('width')), float(e.get('height'))
41
width = %f, height = %f
45
sel = CSSSelector('svg|rect[ink|label="transition"]', ns)
47
x, y = float(e.get('x')), float(e.get('y'))
48
w, h = float(e.get('width')), float(e.get('height'))
51
descSel = CSSSelector('svg|desc', ns)
58
width = %f, height = %f,
63
sel = CSSSelector('svg|rect[ink|label="flower"]', ns)
65
x, y = float(e.get('x')), float(e.get('y'))
73
sel = CSSSelector('svg|rect[ink|label="cat"]', ns)
75
x, y = float(e.get('x')), float(e.get('y'))
83
sel = CSSSelector('svg|rect[ink|label="fish"]', ns)
85
x, y = float(e.get('x')), float(e.get('y'))
86
w, h = float(e.get('width')), float(e.get('height'))
91
width = %f, height = %f,
95
sel = CSSSelector('svg|rect[ink|label="flag"]', ns)
97
x, y = float(e.get('x')), float(e.get('y'))
98
w, h = float(e.get('width')), float(e.get('height'))
103
width = %f, height = %f,
107
sel = CSSSelector('svg|rect[ink|label="fairy"]', ns)
109
x, y = float(e.get('x')), float(e.get('y'))
110
w, h = float(e.get('width')), float(e.get('height'))
115
width = %f, height = %f,
119
sel = CSSSelector('svg|rect[ink|label="gatetrigger"]', ns)
121
x, y = float(e.get('x')), float(e.get('y'))
122
w, h = float(e.get('width')), float(e.get('height'))
127
width = %f, height = %f,
131
sel = CSSSelector('svg|rect[ink|label="fairyactivator"]', ns)
133
x, y = float(e.get('x')), float(e.get('y'))
134
w, h = float(e.get('width')), float(e.get('height'))
139
width = %f, height = %f,
143
sel = CSSSelector('svg|rect[ink|label="troll"]', ns)
145
x, y = float(e.get('x')), float(e.get('y'))
146
#w, h = float(e.get('width')), float(e.get('height'))
158
sel = CSSSelector('svg|rect[ink|label="gateup"]', ns)
160
x, y = float(e.get('x')), float(e.get('y'))
161
w, h = float(e.get('width')), float(e.get('height'))
166
width = %f, height = %f,
167
fill = {108,57,22,255},
172
sel = CSSSelector('svg|rect[ink|label="gatedown"]', ns)
174
x, y = float(e.get('x')), float(e.get('y'))
175
w, h = float(e.get('width')), float(e.get('height'))
180
width = %f, height = %f,
181
fill = {108,57,22,255},
186
sel = CSSSelector('svg|rect[ink|label="fairytarget"]', ns)
188
x, y = float(e.get('x')), float(e.get('y'))
189
w, h = float(e.get('width')), float(e.get('height'))
192
fairytarget = Sprite:new{
194
width = %f, height = %f,