Fill() can only be called between beginShape() and endShape()

Hi -
I’m working through the PShape example and running into a bit of a problem with the following code.
I can’t seem to color fill the shape.
Any suggestions?


PShape square;
void setup() {
  size(400, 400);
  square = createShape(RECT, 0, 0, 80, 80);
}

void draw() {
 
  for (int x=0; x<10; x++){
 square.fill(random(100), random(100), random(100));
 shape(square, 10*x, 10*x);
  };
}

Hello @bcabc ,

See tutorial:

See reference:

:)

1 Like