/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
gate = ''
 
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]
80
82
},
81
83
""" % (x,y,w,h)
82
84
 
 
85
    sel = CSSSelector('svg|rect[ink|label="gatetrigger"]', ns)
 
86
    for e in sel(t):
 
87
        x, y = float(e.get('x')), float(e.get('y'))
 
88
        w, h = float(e.get('width')), float(e.get('height'))
 
89
 
 
90
        print """
 
91
GateTrigger:new{
 
92
  x = %f, y = %f,
 
93
  width = %f, height = %f,
 
94
},
 
95
""" % (x,y,w,h)
 
96
 
83
97
    sel = CSSSelector('svg|rect[ink|label="troll"]', ns)
84
98
    for e in sel(t):
85
99
        x, y = float(e.get('x')), float(e.get('y'))
94
108
 
95
109
    print '},'
96
110
 
 
111
    # gate...
 
112
    sel = CSSSelector('svg|rect[ink|label="gateup"]', ns)
 
113
    for e in sel(t):
 
114
        x, y = float(e.get('x')), float(e.get('y'))
 
115
        w, h = float(e.get('width')), float(e.get('height'))
 
116
 
 
117
        gate = gate + """
 
118
gateup = Fill:new{
 
119
  x = %f, y = %f,
 
120
  width = %f, height = %f,
 
121
  fill = {108,57,22,255},
 
122
  gateup = true
 
123
}
 
124
""" % (x,y,w,h)
 
125
 
 
126
    sel = CSSSelector('svg|rect[ink|label="gatedown"]', ns)
 
127
    for e in sel(t):
 
128
        x, y = float(e.get('x')), float(e.get('y'))
 
129
        w, h = float(e.get('width')), float(e.get('height'))
 
130
 
 
131
        gate = gate + """
 
132
gatedown = Fill:new{
 
133
  x = %f, y = %f,
 
134
  width = %f, height = %f,
 
135
  fill = {108,57,22,255},
 
136
  visible = false
 
137
}
 
138
""" % (x,y,w,h)
 
139
 
 
140
 
97
141
print '}'
 
142
 
 
143
print gate