We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi
I am trying to draw an SVG at 0,0. The dimension of the SVG is 568x568px. But somehow Processing does not draw the SVG at (0,0). Does PShape have a different coordinate system?
PShape floorPlan;
int ellipseSize = 10;
void setup() {
size(1024, 768);
svg = loadShape("svg.svgz");
background(255);
smooth();
}
void draw() {
ellipse(ellipseSize/2, ellipseSize/2, ellipseSize, ellipseSize);
shape(svg, 0, 0);
}
I would like to have the SVG at the center. How do i achieve this please?
Thanks S
Answers
shapeMode(CENTER);
But it cann well be that it’s positioned at 300 or so I guess
Then you need to translate it
Thanks Chrisir. With shapeMode(CENTER), it's still not centered. This is the SVG code.
I'm thinking this is the culprit in the SVG code.
viewBox="-110 393 568 568"
Please share your thoughts.
Cheers
Right. Nothing about your actual SVG data in the SVG file is centered -- not the viewbox, or the background, or the rects. where did you get it? Can you just draw another SVG that better suits your needs? If not, you should translate by either the canvas offsets or the canvas - content offsets.
Luckily the SVG coordinate system is similar to Processing -- 0,0 is upper left corner.