1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

SVG import and rotate.

Posted by jkyle on Nov 25, 2007

After I read in an SVG file, I would like to draw it multiple times, rotating it each time. It seems, though, that the program applies the rotation to each path, even though the rotate is outside of the for loop.

Any ideas why this might be happening?

size(500,2000)
svg = ximport("svg")
 
data = open("dino.svg").read()
paths = svg.parse(data)
 
for i in range(5):
    for path in paths:
        try:
            fill(path.fill)
        except:
            fill(random(), 0, 0)
        drawpath(path.copy())
    rotate(i*20)


 
Posted by Giorgio O. on Nov 25, 2007

Hello jkyle,

it seems that it might helpful if you'll take a look at this page
http://www.nodebox.net/code/index.php/Graphics_State

I didn't test out your code, but it might be a problem of transformation matrix 'state'.

maybe this snippep of code can be helpful:

size(500,500)
transform(mode=CORNER)
 
for i in range(7):
    translate(250,250)
    rotate(20*i)
    rect(0,0,100,1)
    reset()