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 & HelpPrograms › SVG size and center problem
Page Index Toggle Pages: 1
SVG size and center problem ? (Read 780 times)
SVG size and center problem ?
Apr 16th, 2009, 10:31am
 
Hi there,

I am not new to Processing but new to SVG.

I am developping interactive map based on SVG
(not read data visualization from Mister Fry yet but I am waiting for it..).

I am using an SVG world map from wikipedia.
The SVG looks all fine under both Adobe illustrator and Inkscape.

When using it with Processing I have two problems perhaps related one to another : size is wrong and impossible to center.

Here is my code :
Code:


PShape essai;

void setup()
{
 size(1000,700);
 smooth();
 // want to place the object in the middle of the screen
 shapeMode(CENTER);
 
 // download the file from en.wikipedia.org/wiki/File:BlankMap-World6.svg
 essai=loadShape("BlankMap-World6.svg");
 
 // what's the metadata size info ?
 //width:939.74725 height:476.7276
 println(essai.width+" "+essai.height);
 
 // make the svg visible by styling it
 essai.disableStyle();
 stroke(0);

// here we go
 shape(essai,width/2,height/2,essai.width,essai.height);
 // 2 problems :
 // 1- the size of the shape is huge
 //    putting width and height argument in shape doesn't matter
 //    I have to scale it down by 0.36 so that it feets in 1000x700 screen
 // 2- not centered at all
 
 // just to have a visible center
 fill(0,255,0);
 ellipse(width/2,height/2,5,5);
}


void draw()
{
 // nothing yet unfortunately ...
}


Is that a bug ?
Is the SVG wrong in any manner ?
Or did I miss something ?

Thanks a lot for your help

Paul

ps: thanks a lot guys for your work, Processing's amazing Wink
Re: SVG size and center problem ?
Reply #1 - Apr 17th, 2009, 7:08am
 
The fact that its huge is because you put essai.width and essai,height in the shape()  if you say   shape(essai,width/2,height/2,width,height); it should work. But as i tested it i found out that there is something wrong with the worldmap... if you use for example http://en.wikipedia.org/wiki/File:WMD_world_map.svg instead. everything works fine.

edit: your windows should have the same ratio as your map, if not dont use with,height
Re: SVG size and center problem ?
Reply #2 - Apr 17th, 2009, 8:07am
 
Hi Cedric,

Actually this post is a copy (my mistake.. oups) of that one :
http://processing.org/discourse/yabb2/num_1239903063.html

To follow up your post, adding width and height doesn't change anything.
Indeed the other map works fine.

This confirms my conclusion (see the other post) which basically says tht if your file isn't a well-formed SVG you better use geomerative which handle the map correctly.

thanks for your help !

Paul
Page Index Toggle Pages: 1