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

**URL:** https://discourse.processing.org/t/fill-can-only-be-called-between-beginshape-and-endshape/37738
**Category:** Beginners
**Created:** [June 27, 2022, 7:10pm UTC](https://discourse.processing.org/t/fill-can-only-be-called-between-beginshape-and-endshape/37738 "2022-06-27T19:10:55Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bcabc](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@bcabc](https://discourse.processing.org/u/bcabc)
#### Post date: [June 27, 2022, 7:10pm UTC](https://discourse.processing.org/t/fill-can-only-be-called-between-beginshape-and-endshape/37738/1 "2022-06-27T19:10:55Z")

</div>

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?

```auto

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);
  };
}

```

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [June 27, 2022, 7:19pm UTC](https://discourse.processing.org/t/fill-can-only-be-called-between-beginshape-and-endshape/37738/2 "2022-06-27T19:19:42Z")

</div>

Hello @bcabc ,

See tutorial:

> **[PShape](https://processing.org/tutorials/pshape/)**
>
> How to use the PShape class in Processing.

See reference:

> **[Reference](https://processing.org/reference/PShape_setFill_.html)**
>
> The setFill() method defines the fill color of a PShape. This method is used after shapes are created or when a shape is defined explicitly (e.g. createShape(RECT, 20, 20, 80, 80)…

`:)`
