/ld26

To get this branch, use:
bzr branch /bzr/ld26

« back to all changes in this revision

Viewing changes to svg_levels.py

  • Committer: Josh C
  • Date: 2013-04-29 00:35:28 UTC
  • Revision ID: josh@9ix.org-20130429003528-6o7b23zq3c4m8nxe
be moved

Show diffs side-by-side

added added

removed removed

11
11
ns = {'svg': 'http://www.w3.org/2000/svg',
12
12
      'ink': 'http://www.inkscape.org/namespaces/inkscape'}
13
13
 
14
 
gate = ''
 
14
other = ''
15
15
 
16
16
for svg in glob.glob('data/*.svg'):
17
17
    t = etree.parse(svg)
30
30
},
31
31
""" % (x,y,w,h)
32
32
 
 
33
    sel = CSSSelector('svg|rect[ink|label="maybedisplace"]', ns)
 
34
    for e in sel(t):
 
35
        x, y = float(e.get('x')), float(e.get('y'))
 
36
        w, h = float(e.get('width')), float(e.get('height'))
 
37
 
 
38
        print """
 
39
MaybeDisplacer:new{
 
40
  x = %f, y = %f,
 
41
  width = %f, height = %f
 
42
},
 
43
""" % (x,y,w,h)
 
44
 
33
45
    sel = CSSSelector('svg|rect[ink|label="transition"]', ns)
34
46
    for e in sel(t):
35
47
        x, y = float(e.get('x')), float(e.get('y'))
116
128
},
117
129
""" % (x,y,w,h)
118
130
 
 
131
    sel = CSSSelector('svg|rect[ink|label="fairyactivator"]', ns)
 
132
    for e in sel(t):
 
133
        x, y = float(e.get('x')), float(e.get('y'))
 
134
        w, h = float(e.get('width')), float(e.get('height'))
 
135
 
 
136
        print """
 
137
FairyActivator:new{
 
138
  x = %f, y = %f,
 
139
  width = %f, height = %f,
 
140
},
 
141
""" % (x,y,w,h)
 
142
 
119
143
    sel = CSSSelector('svg|rect[ink|label="troll"]', ns)
120
144
    for e in sel(t):
121
145
        x, y = float(e.get('x')), float(e.get('y'))
136
160
        x, y = float(e.get('x')), float(e.get('y'))
137
161
        w, h = float(e.get('width')), float(e.get('height'))
138
162
 
139
 
        gate = gate + """
 
163
        other = other + """
140
164
gateup = Fill:new{
141
165
  x = %f, y = %f,
142
166
  width = %f, height = %f,
150
174
        x, y = float(e.get('x')), float(e.get('y'))
151
175
        w, h = float(e.get('width')), float(e.get('height'))
152
176
 
153
 
        gate = gate + """
 
177
        other = other + """
154
178
gatedown = Fill:new{
155
179
  x = %f, y = %f,
156
180
  width = %f, height = %f,
159
183
}
160
184
""" % (x,y,w,h)
161
185
 
 
186
    sel = CSSSelector('svg|rect[ink|label="fairytarget"]', ns)
 
187
    for e in sel(t):
 
188
        x, y = float(e.get('x')), float(e.get('y'))
 
189
        w, h = float(e.get('width')), float(e.get('height'))
 
190
 
 
191
        other = other + """
 
192
fairytarget = Sprite:new{
 
193
  x = %f, y = %f,
 
194
  width = %f, height = %f,
 
195
  visible = false
 
196
}
 
197
""" % (x,y,w,h)
 
198
 
162
199
 
163
200
print '}'
164
201
 
165
 
print gate
 
202
print other