benfry / processing4

Processing 4.x releases for Java 17
https://processing.org
Other
1.31k stars 236 forks source link

Drawing the same SVG with different stroke weights causes rendering bug with P2D renderer #817

Open cadin opened 6 months ago

cadin commented 6 months ago

Description

When drawing an SVG shape (with style disabled) using the P2D renderer, the rendering will glitch if the shape is drawn more than once with a different stroke weight.

Expected Behavior

The shape should appear on the canvas at different stroke weights.

Current Behavior

The first instance of the shape appears as expected. Subsequent shapes (drawn after changing strokeWeight) are drawn with a glitched stroke.

Steps to Reproduce

  1. Set up sketch with P2D renderer.
  2. Load an SVG into a PShape and call disableStyle() on it.
  3. Draw the shape to the screen once, then change strokeWeight and draw again.

Example code (from this repo with SVG file included):

PShape aSVG;

void setup() {
  size(600, 300, P2D); // changing to default renderer works

  aSVG = loadShape("A.svg");
  aSVG.disableStyle();
}

void draw() {
  background(255);
  scale(3);

  strokeWeight(1);
  shape(aSVG); // removing this first shape works

  strokeWeight(3); // removing this stroke change works
  shape(aSVG, 100, 0);
}

Your Environment

Workarounds

cadin commented 6 months ago

Not sure why I can't attach images here, but you can see screenshots in the linked repo

clankill3r commented 4 months ago

Extra info, I tested it on windows and the same thing happens.