/ld26

To get this branch, use:
bzr branch http://9ix.org/bzr/ld26

« back to all changes in this revision

Viewing changes to svg_levels.py

  • Committer: Josh C
  • Date: 2013-04-28 01:21:46 UTC
  • Revision ID: josh@9ix.org-20130428012146-42c1hx6r1g7y1kgu
fadeĀ in

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
ns = {'svg': 'http://www.w3.org/2000/svg',
12
12
      'ink': 'http://www.inkscape.org/namespaces/inkscape'}
13
13
 
14
 
gate = ''
15
 
 
16
14
for svg in glob.glob('data/*.svg'):
17
15
    t = etree.parse(svg)
18
16
    basefile = os.path.basename(svg).split('.')[0]
48
46
},
49
47
""" % (x,y,w,h, desc)
50
48
 
51
 
    sel = CSSSelector('svg|rect[ink|label="flower"]', ns)
52
 
    for e in sel(t):
53
 
        x, y = float(e.get('x')), float(e.get('y'))
54
 
 
55
 
        print """
56
 
Flower:new{
57
 
  x = %f, y = %f,
58
 
},
59
 
""" % (x,y)
60
 
 
61
 
    sel = CSSSelector('svg|rect[ink|label="cat"]', ns)
62
 
    for e in sel(t):
63
 
        x, y = float(e.get('x')), float(e.get('y'))
64
 
 
65
 
        print """
66
 
Cat:new{
67
 
  x = %f, y = %f,
68
 
},
69
 
""" % (x,y)
70
 
 
71
 
    sel = CSSSelector('svg|rect[ink|label="fish"]', ns)
72
 
    for e in sel(t):
73
 
        x, y = float(e.get('x')), float(e.get('y'))
74
 
        w, h = float(e.get('width')), float(e.get('height'))
75
 
 
76
 
        print """
77
 
Fish:new{
78
 
  x = %f, y = %f,
79
 
  width = %f, height = %f,
80
 
},
81
 
""" % (x,y,w,h)
82
 
 
83
 
    sel = CSSSelector('svg|rect[ink|label="flag"]', 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
 
Flag: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="fairy"]', 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
 
Fairy: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="gatetrigger"]', 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
 
GateTrigger: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="troll"]', 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
 
Troll:new{
126
 
  x = %f, y = %f,
127
 
},
128
 
""" % (x,y)
129
 
 
130
 
 
131
49
    print '},'
132
50
 
133
 
    # gate...
134
 
    sel = CSSSelector('svg|rect[ink|label="gateup"]', ns)
135
 
    for e in sel(t):
136
 
        x, y = float(e.get('x')), float(e.get('y'))
137
 
        w, h = float(e.get('width')), float(e.get('height'))
138
 
 
139
 
        gate = gate + """
140
 
gateup = Fill:new{
141
 
  x = %f, y = %f,
142
 
  width = %f, height = %f,
143
 
  fill = {108,57,22,255},
144
 
  gateup = true
145
 
}
146
 
""" % (x,y,w,h)
147
 
 
148
 
    sel = CSSSelector('svg|rect[ink|label="gatedown"]', ns)
149
 
    for e in sel(t):
150
 
        x, y = float(e.get('x')), float(e.get('y'))
151
 
        w, h = float(e.get('width')), float(e.get('height'))
152
 
 
153
 
        gate = gate + """
154
 
gatedown = Fill:new{
155
 
  x = %f, y = %f,
156
 
  width = %f, height = %f,
157
 
  fill = {108,57,22,255},
158
 
  visible = false
159
 
}
160
 
""" % (x,y,w,h)
161
 
 
162
 
 
163
51
print '}'
164
 
 
165
 
print gate