processing-android icon indicating copy to clipboard operation
processing-android copied to clipboard

LoadShape fails for some svgs in Android mode

Open phanirithvij opened this issue 6 years ago • 3 comments

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 kiwi

But this svg is getting rendered correctly. orange-svg 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).

phanirithvij avatar Jul 22 '19 08:07 phanirithvij

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.

phanirithvij avatar Jul 23 '19 10:07 phanirithvij

Thanks for reporting this. I wonder if the problem affects the java mode as well, will look into it shortly.

codeanticode avatar Oct 14 '19 03:10 codeanticode

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.

codeanticode avatar Oct 22 '19 01:10 codeanticode