/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-28 23:14:19 UTC
  • Revision ID: josh@9ix.org-20130428231419-930dlct49eh71pr8
gate

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
 
other = ''
 
14
gate = ''
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
 
 
45
33
    sel = CSSSelector('svg|rect[ink|label="transition"]', ns)
46
34
    for e in sel(t):
47
35
        x, y = float(e.get('x')), float(e.get('y'))
70
58
},
71
59
""" % (x,y)
72
60
 
73
 
    sel = CSSSelector('svg|rect[ink|label="cat"]', ns)
74
 
    for e in sel(t):
75
 
        x, y = float(e.get('x')), float(e.get('y'))
76
 
 
77
 
        print """
78
 
Cat:new{
79
 
  x = %f, y = %f,
80
 
},
81
 
""" % (x,y)
82
 
 
83
61
    sel = CSSSelector('svg|rect[ink|label="fish"]', ns)
84
62
    for e in sel(t):
85
63
        x, y = float(e.get('x')), float(e.get('y'))
104
82
},
105
83
""" % (x,y,w,h)
106
84
 
107
 
    sel = CSSSelector('svg|rect[ink|label="fairy"]', ns)
108
 
    for e in sel(t):
109
 
        x, y = float(e.get('x')), float(e.get('y'))
110
 
        w, h = float(e.get('width')), float(e.get('height'))
111
 
 
112
 
        print """
113
 
Fairy:new{
114
 
  x = %f, y = %f,
115
 
  width = %f, height = %f,
116
 
},
117
 
""" % (x,y,w,h)
118
 
 
119
85
    sel = CSSSelector('svg|rect[ink|label="gatetrigger"]', ns)
120
86
    for e in sel(t):
121
87
        x, y = float(e.get('x')), float(e.get('y'))
128
94
},
129
95
""" % (x,y,w,h)
130
96
 
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
 
 
143
 
    sel = CSSSelector('svg|rect[ink|label="boat"]', ns)
144
 
    for e in sel(t):
145
 
        x, y = float(e.get('x')), float(e.get('y'))
146
 
        #w, h = float(e.get('width')), float(e.get('height'))
147
 
 
148
 
        print """
149
 
Boat:new{
150
 
  x = %f, y = %f,
151
 
},
152
 
""" % (x,y)
153
 
 
154
97
    sel = CSSSelector('svg|rect[ink|label="troll"]', ns)
155
98
    for e in sel(t):
156
99
        x, y = float(e.get('x')), float(e.get('y'))
171
114
        x, y = float(e.get('x')), float(e.get('y'))
172
115
        w, h = float(e.get('width')), float(e.get('height'))
173
116
 
174
 
        other = other + """
 
117
        gate = gate + """
175
118
gateup = Fill:new{
176
119
  x = %f, y = %f,
177
120
  width = %f, height = %f,
185
128
        x, y = float(e.get('x')), float(e.get('y'))
186
129
        w, h = float(e.get('width')), float(e.get('height'))
187
130
 
188
 
        other = other + """
 
131
        gate = gate + """
189
132
gatedown = Fill:new{
190
133
  x = %f, y = %f,
191
134
  width = %f, height = %f,
194
137
}
195
138
""" % (x,y,w,h)
196
139
 
197
 
    sel = CSSSelector('svg|rect[ink|label="fairytarget"]', ns)
198
 
    for e in sel(t):
199
 
        x, y = float(e.get('x')), float(e.get('y'))
200
 
        w, h = float(e.get('width')), float(e.get('height'))
201
 
 
202
 
        other = other + """
203
 
fairytarget = Sprite:new{
204
 
  x = %f, y = %f,
205
 
  width = %f, height = %f,
206
 
  visible = false
207
 
}
208
 
""" % (x,y,w,h)
209
 
 
210
140
 
211
141
print '}'
212
142
 
213
 
print other
 
143
print gate