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 700 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, 2:58am
 
Thanks to previous post I jumped into Geomerative to deal with my SVG and all problems are gone.

So do you think I should post my problem with the native processing SVG management ("old candy") in bug section ?

Paul
Re: SVG size and center problem ?
Reply #2 - Apr 17th, 2009, 3:33am
 
I could take a closer look at the issue.
The problem is that height and width data in this file are inaccurate: even a casual glance at the first path (ocean) shows coordinates above 2700...
I copied the values from the viewBox to these dimensions, and bam! map is centered... But still huge, as it is bigger than the sketch size.
I don't recall enough of SVG standard to call this a bug in Processing, though. But I doubt it, it is more the fault of the map file...
Re: SVG size and center problem ?
Reply #3 - Apr 17th, 2009, 6:10am
 
right.
Thanks for the look on the subject.

To sum up and conclude, facts are :
- problems with some files coming from the web and which are clearly not totally well-formed under the built-in SVG processing library
- same files are handled correctly by other library like Geomerative

My conclusion would be that your SVG file has to be clear and well-formed so that built-in SVG in processing can handle it otherwise give a try to geomerative...
So not a bug but rather SVG format conpatibility issues.

Paul

Page Index Toggle Pages: 1