import processing.svg.*;
float reso;
void setup() {
size(800, 800);
reso = width;
beginRecord(SVG,"a.svg");
}
void draw() {
background(0);
PVector center = new PVector(reso/2,reso-5);
//float center = reso/2;
float radius = reso/1.9;
float xoff = reso/2.3;
float yoff = reso/1.48;
translate(center.x,center.y);
//translate(0,-center.y+5);
//rotate(PI);
PVector point1 = new PVector(-xoff,-yoff);
PVector point2 = new PVector(radius * cos(radians(230)), - yoff + radius * sin(radians(230)));
PVector point3 = new PVector(radius * cos(radians(-50)), - yoff + radius * sin(radians(-50)));
PVector point4 = new PVector(xoff,-yoff);
PShape s1 = createShape(PShape.PATH);
s1.beginShape();
s1.noStroke();
s1.vertex(point1.x,point1.y);
s1.bezierVertex(point2.x,point2.y,point3.x,point3.y,point4.x,point4.y);
s1.vertex(xoff,0);
s1.vertex(-xoff,0);
s1.endShape(CLOSE);
shape(s1,0,0);
endRecord();
}
PShape shape;
void setup(){
size(800,800,P2D);
shape = loadShape("a.svg");
noLoop();
}
void draw(){
background(0);
translate(width/2,height-5);
shape(shape,0,0,500,250);
}
I want to access the shape’s original width & height and manipulate it when I import it maintaining the aspect ratio of the shape. But it kind of comes out distorted. When using the scale function , it accumulates as it changes the shape size directly causing the shape to get huge or disappear in few frames.
Also the size is different when imported with P2D renderer and default renderer.