/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:42:39 UTC
  • Revision ID: josh@9ix.org-20130429004239-r0yedw9bxk7infzs
drop

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 = ''
 
15
 
14
16
for svg in glob.glob('data/*.svg'):
15
17
    t = etree.parse(svg)
16
18
    basefile = os.path.basename(svg).split('.')[0]
28
30
},
29
31
""" % (x,y,w,h)
30
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
 
31
45
    sel = CSSSelector('svg|rect[ink|label="transition"]', ns)
32
46
    for e in sel(t):
33
47
        x, y = float(e.get('x')), float(e.get('y'))
56
70
},
57
71
""" % (x,y)
58
72
 
 
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
    sel = CSSSelector('svg|rect[ink|label="fish"]', ns)
 
84
    for e in sel(t):
 
85
        x, y = float(e.get('x')), float(e.get('y'))
 
86
        w, h = float(e.get('width')), float(e.get('height'))
 
87
 
 
88
        print """
 
89
Fish:new{
 
90
  x = %f, y = %f,
 
91
  width = %f, height = %f,
 
92
},
 
93
""" % (x,y,w,h)
 
94
 
 
95
    sel = CSSSelector('svg|rect[ink|label="flag"]', ns)
 
96
    for e in sel(t):
 
97
        x, y = float(e.get('x')), float(e.get('y'))
 
98
        w, h = float(e.get('width')), float(e.get('height'))
 
99
 
 
100
        print """
 
101
Flag:new{
 
102
  x = %f, y = %f,
 
103
  width = %f, height = %f,
 
104
},
 
105
""" % (x,y,w,h)
 
106
 
 
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
    sel = CSSSelector('svg|rect[ink|label="gatetrigger"]', ns)
 
120
    for e in sel(t):
 
121
        x, y = float(e.get('x')), float(e.get('y'))
 
122
        w, h = float(e.get('width')), float(e.get('height'))
 
123
 
 
124
        print """
 
125
GateTrigger:new{
 
126
  x = %f, y = %f,
 
127
  width = %f, height = %f,
 
128
},
 
129
""" % (x,y,w,h)
 
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
 
 
143
    sel = CSSSelector('svg|rect[ink|label="troll"]', 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
Troll:new{
 
150
  x = %f, y = %f,
 
151
},
 
152
""" % (x,y)
 
153
 
 
154
 
59
155
    print '},'
60
156
 
 
157
    # gate...
 
158
    sel = CSSSelector('svg|rect[ink|label="gateup"]', ns)
 
159
    for e in sel(t):
 
160
        x, y = float(e.get('x')), float(e.get('y'))
 
161
        w, h = float(e.get('width')), float(e.get('height'))
 
162
 
 
163
        other = other + """
 
164
gateup = Fill:new{
 
165
  x = %f, y = %f,
 
166
  width = %f, height = %f,
 
167
  fill = {108,57,22,255},
 
168
  gateup = true
 
169
}
 
170
""" % (x,y,w,h)
 
171
 
 
172
    sel = CSSSelector('svg|rect[ink|label="gatedown"]', ns)
 
173
    for e in sel(t):
 
174
        x, y = float(e.get('x')), float(e.get('y'))
 
175
        w, h = float(e.get('width')), float(e.get('height'))
 
176
 
 
177
        other = other + """
 
178
gatedown = Fill:new{
 
179
  x = %f, y = %f,
 
180
  width = %f, height = %f,
 
181
  fill = {108,57,22,255},
 
182
  visible = false
 
183
}
 
184
""" % (x,y,w,h)
 
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
 
 
199
 
61
200
print '}'
 
201
 
 
202
print other