LoadShape fails for some svgs in Android mode
When I use loadShape with some SVGs it's not rendering properly in Android mode.
But it's getting rendered correctly in the java mode.
This is one such svg
But this svg is getting rendered correctly.
I've put together this simple code that demos what I mean.
PShape svg;
int num = 1;
String[] assets = {
"tomato.svg", "ogears.svg", "watermelon.svg", "kiwi.svg"
};
void settings() {
size(displayWidth, displayHeight);
}
void setup(){
svg = loadShape(assets[num]);
}
void draw(){
background(255);
push();
scale(map(mouseY, 0, height, 0, 1));
shape(svg);
push();
noFill();
stroke(0);
strokeWeight(1);
rect(0, 0, svg.width, svg.height);
pop();
pop();
}
void push(){
pushMatrix();
pushStyle();
}
void pop(){
popStyle();
popMatrix();
}
void mousePressed(){
num++;
num = num % 4;
svg = loadShape(assets[num]);
}
A simple project file which can be opened with processing SVGTests.zip
And it is not working even when I use size(.., .., P2D).
I think the issue is with rendering <circle> tags. I asked a question on stackoverflow and I answered it.
For anyone who's facing a similar issue.
Thanks for reporting this. I wonder if the problem affects the java mode as well, will look into it shortly.
Porting recent changes from PShape in Java mode solves this SVG rendering issue with the P2D and P3D renderers. But rendering is still glitchy with the default renderer (Android2D), and specifically when scaling the shape with a value diff from 1. So this should be caused by some bug in the transformation handling in Android2D.
I'm going to tag it as Android2D, and clear it from the 4.1 milestone. For the time being, a workaround to render SVGs correctly is to use the P2D/P3D renderers.