We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › translating part of a svg file
Page Index Toggle Pages: 1
translating part of a svg file (Read 589 times)
translating part of a svg file
Mar 7th, 2010, 7:04am
 
suppose there is a box in a svg image
can view the full image using this code
Code:

PShape fullimage=loadShape("img1.svg");
shape(fullimage)


consider this code

Code:

PShape tt=fullmap.getChild("box");
tt.disableStyle();
fill(0, 51, 102);
shape(tt);



this wil make that "box" appear exactly at the same possition at it was. although the rest of the image is invisible

what if i want to change to possition of that box...
is there any method to do it ?


thanks

Re: translating part of a svg file
Reply #1 - Mar 7th, 2010, 7:33am
 
if it was a rectangle i can calculate the amount of translation needed to re-possition the object by using its parameters.

but with svg files how to do that ?


thanks in advance
Re: translating part of a svg file
Reply #2 - Mar 7th, 2010, 9:08am
 
You can use x, y parameters of shape().
Or use translate() before drawing it.
But I suppose the question is to know the position of the shape relative to the origin of the whole SVG image. I admit I don't know, perhaps you are supposed to know this info if you made the shape...
Re: translating part of a svg file
Reply #3 - Mar 7th, 2010, 9:16am
 
yup that is the question.
i can find the cordinates of that part of the shape (atleast top left corner) using inkscape .
but then i have to hard code the cordinates. is it a good practice ?
Page Index Toggle Pages: 1