Skip to content

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

Open
@vsquared

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: PShape.setFill() no longer works #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

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions