# How to get the colour of a PShape?

**URL:** <https://discourse.processing.org/t/how-to-get-the-colour-of-a-pshape/19787>\
**Category:** Coding Questions\
**Created:** [April 14, 2020, 10:05pm UTC](https://discourse.processing.org/t/how-to-get-the-colour-of-a-pshape/19787 "2020-04-14T22:05:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cybernet](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@Cybernet](https://discourse.processing.org/u/Cybernet)\
**Post date:** [April 14, 2020, 10:05pm UTC](https://discourse.processing.org/t/how-to-get-the-colour-of-a-pshape/19787/1 "2020-04-14T22:05:18Z")

</div>

I have a Pshape like this:

```auto
PShape s;
s.setFill(0);

if (s colour == color(0))

```

How do I detect the PShape colour?

Do I have to create my own PShape class?

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [April 14, 2020, 11:05pm UTC](https://discourse.processing.org/t/how-to-get-the-colour-of-a-pshape/19787/2 "2020-04-14T23:05:30Z")

</div>

I’ve tested this code that works on certain renderers.  
I’ts on [this](https://forum.processing.org/two/discussion/5274/how-to-get-the-color-from-a-pshape-object) link where GoToLoop also has another solution.

```auto
void setup() {
  size(200, 200, P2D);
  PShape bli = createShape();
  bli.beginShape();
  bli.fill(#ff0000);
  bli.vertex(0, 0);
  bli.fill(#00ff00);
  bli.vertex(100, 100);
  bli.fill(#0000ff);
  bli.vertex(10, 100);
  bli.endShape(CLOSE);

  shape(bli);

  fill( bli.getFill(0) ); //this only works with a renderer (p2d, etc)
  rect(40, 40, 40, 40);
  fill( bli.getFill(1) ); 
  rect(60, 60, 40, 40);
  fill( bli.getFill(2) ); 
  rect(80, 80, 40, 40);
}

```
