/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-27 19:17:32 UTC
  • Revision ID: josh@9ix.org-20130427191732-b04lkepq9cz8e1n7
player min/maxY on a level

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
 
3
 
# ./svg_levels.py >svg_levels.lua
4
 
 
5
 
import os, glob
6
 
from lxml import etree
7
 
from lxml.cssselect import CSSSelector
8
 
 
9
 
print '-- autogenerated by svg_levels.py\n\nsvg_objects = {'
10
 
 
11
 
ns = {'svg': 'http://www.w3.org/2000/svg',
12
 
      'ink': 'http://www.inkscape.org/namespaces/inkscape'}
13
 
    
14
 
for svg in glob.glob('data/*.svg'):
15
 
    t = etree.parse(svg)
16
 
    basefile = os.path.basename(svg).split('.')[0]
17
 
    print '%s = {' % basefile
18
 
 
19
 
    sel = CSSSelector('svg|rect[ink|label="displace"]', ns)
20
 
    for e in sel(t):
21
 
        x, y = float(e.get('x')), float(e.get('y'))
22
 
        w, h = float(e.get('width')), float(e.get('height'))
23
 
        
24
 
        print """
25
 
Displacer:new{
26
 
  x = %f, y = %f,
27
 
  width = %f, height = %f
28
 
}
29
 
""" % (x,y,w,h)
30
 
 
31
 
    print '},'
32
 
 
33
 
print '}'