processing / processing/processing4

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

Open
#817 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug core
Dominant language
Java
Stars
494
Forks
183
Avg merge
4h 39m
Merged PRs (30d)
3

Description

Created by: cadin

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

  • Processing version: 4.3
  • Operating System and OS version: Mac OS 14.2.1 (Intel)

Workarounds

  • Using the default renderer works as expected
  • Drawing the shape only once (with any stroke weight) works as expected
  • Drawing the shape multiple times without changing stroke weight works as expected
  • Loading the same SVG into a separate PShape instance to render as the second graphic works as expected

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided P2D sketch and SVG reproduction, then trace the P2D renderer's handling of repeated disabled-style PShape draws and changing strokeWeight values. Confirm the fix by reproducing the sketch and verifying both rendered shapes have the requested stroke weights without glitches.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.