/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 22:53:39 UTC
  • Revision ID: josh@9ix.org-20130427225339-6b4me5c8wi7y3jl0
pull data from svg to place objects into the world

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
ns = {'svg': 'http://www.w3.org/2000/svg',
12
12
      'ink': 'http://www.inkscape.org/namespaces/inkscape'}
13
 
 
 
13
    
14
14
for svg in glob.glob('data/*.svg'):
15
15
    t = etree.parse(svg)
16
16
    basefile = os.path.basename(svg).split('.')[0]
20
20
    for e in sel(t):
21
21
        x, y = float(e.get('x')), float(e.get('y'))
22
22
        w, h = float(e.get('width')), float(e.get('height'))
23
 
 
 
23
        
24
24
        print """
25
25
Displacer:new{
26
26
  x = %f, y = %f,
27
27
  width = %f, height = %f
28
 
},
 
28
}
29
29
""" % (x,y,w,h)
30
30
 
31
 
    sel = CSSSelector('svg|rect[ink|label="transition"]', ns)
32
 
    for e in sel(t):
33
 
        x, y = float(e.get('x')), float(e.get('y'))
34
 
        w, h = float(e.get('width')), float(e.get('height'))
35
 
 
36
 
        desc = ""
37
 
        descSel = CSSSelector('svg|desc', ns)
38
 
        for d in descSel(e):
39
 
            desc = desc + d.text
40
 
 
41
 
        print """
42
 
Transition:new{
43
 
  x = %f, y = %f,
44
 
  width = %f, height = %f,
45
 
  %s
46
 
},
47
 
""" % (x,y,w,h, desc)
48
 
 
49
31
    print '},'
50
32
 
51
33
print '}'