processing / processing/processing4

PShape setFill(indx, color) not working in Processing 4

Open
#900 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Most appropriate sub-area of Processing 4?

OpenGL

Processing version

4.3

Operating system

MacOSX

Steps to reproduce this

"1. The source code below demonstrates the problem. The PShape should change color when the mouse is clicked.

  1. The source code runs correctly in versions 2.2.1 (macos) and 3.5.4 (reported by another forum member running Windows) indicating a runtime code change prior to version 4.

  2. There is a similar report from a year ago: https://github.com/processing/processing4/issues/677"

  3. We would like to change the vertex colors of the original PShape object without having to create a second object.

snippet

PShape t;

void setup() {
  size(400, 400, P2D);
  surface.setTitle("Should change color when mouse clicked.");
  t = createShape();
  t.beginShape();
  t.vertex(200, 100);
  t.vertex(100, 300);
  t.vertex(300, 300);
  t.endShape(CLOSE);
  for (int i = 0; i < t.getVertexCount(); i++) {
    t.setFill(i, color(random(255), random(255), random(255)));
  }
}

void draw() {
  background(209);
  shape(t);
}

void mousePressed() {
  for (int i = 0; i < t.getVertexCount(); i++) {
    t.getVertex(i);
    t.setFill(i, color(random(255), random(255), random(255)));
  }
}
Additional context

No response

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 by tracing PShape.setFill(int, color) through the Processing 4 OpenGL path, using the supplied sketch to reproduce the behavior. Compare the current behavior with Processing 2.2.1 and 3.5.4 if available, and verify that clicking the mouse changes vertex colors on the original PShape without creating a second object.

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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.