# PShape createShape(GROUP) ignoring noStroke(), fill() when contained in PGraphics?

**URL:** <https://discourse.processing.org/t/pshape-createshape-group-ignoring-nostroke-fill-when-contained-in-pgraphics/36508>\
**Category:** Coding Questions\
**Created:** [April 21, 2022, 8:11pm UTC](https://discourse.processing.org/t/pshape-createshape-group-ignoring-nostroke-fill-when-contained-in-pgraphics/36508 "2022-04-21T20:11:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![disuye](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@disuye](https://discourse.processing.org/u/disuye)\
**Post date:** [April 21, 2022, 8:11pm UTC](https://discourse.processing.org/t/pshape-createshape-group-ignoring-nostroke-fill-when-contained-in-pgraphics/36508/1 "2022-04-21T20:11:39Z")

</div>

Not sure if I’m missing something … I’m having trouble getting shapes (approx. 100 shapes, generated by a for loop in setup(), using the method .addChild() to create a group that is visible OK in draw()) to accept _any_ styling when contained within PGraphics beginDraw() ~ endDraw().

If I draw a primitive within the PGraphics say, beginDraw(), pg.rect(), endDraww() then I can alter styling with pg.fill() and pg.noStroke() etc. etc… … but my shape group remains stuck on default styling no matter what I do (black stroke, white fill).

Are there any caveats when using shape groups in PGraphics? Happy to paste some of my code here.

---

<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:** [April 21, 2022, 10:08pm UTC](https://discourse.processing.org/t/pshape-createshape-group-ignoring-nostroke-fill-when-contained-in-pgraphics/36508/2 "2022-04-21T22:08:33Z")

</div>

Hello,

I cooked this up:

> **Example**
>
> ```auto
> PShape house;
> PGraphics pg;
> 
> boolean toggle;
> 
> void setup() 
> {
> size(200, 200);
> 
> // Make a group PShape
>   
> pg = createGraphics(200, 200);
> house = createShape(GROUP);
>   
> // Make three shapes
> PShape path = createShape();
> path.beginShape();
> path.vertex(-20, -20);
> path.vertex(0, -40);
> path.vertex(20, -20);
> path.endShape();
>   
> //fill(128);
> PShape rectangle = createShape(RECT, -20, -20, 40, 40);
> PShape circle = createShape(ELLIPSE, 0, 0, 20, 20);
>   
> // Add all three as children
> house.addChild(path);
> house.addChild(rectangle);
> house.addChild(circle);
>   
> //pg.beginDraw();
> ////house.disableStyle();
> //pg.fill(color(255, 0, 0));
> //pg.stroke(color(255, 255, 0));
> //pg.shapeMode(CENTER);
> //pg.shape(house, pg.width/2, pg.height/2);
> //pg.endDraw();
> }
> 
> void draw() 
> {
> background(52);
>   
> pg.beginDraw();
> if (toggle) 
> house.disableStyle();
> else
> house.enableStyle();
> pg.fill(color(255, 0, 0));
> pg.stroke(color(255, 255, 0));
> pg.shapeMode(CENTER);
> pg.shape(house, pg.width/2, pg.height/2);
> pg.endDraw();
>   
> image(pg, mouseX-width/2, mouseY-height/2);
> }
>   
> void keyPressed()
> {
> toggle = !toggle;
> }
> 
> ```

I modified this example:  
[https://processing.org/reference/PShape\_addChild\_.html](https://processing.org/reference/PShape_addChild_.html)

Reference:  
[https://processing.org/reference/PShape\_disableStyle\_.html](https://processing.org/reference/PShape_disableStyle_.html)

`:)`

---

<div class="post-metadata">

**Author:** ![disuye](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@disuye](https://discourse.processing.org/u/disuye)\
**Post date:** [April 22, 2022, 8:06am UTC](https://discourse.processing.org/t/pshape-createshape-group-ignoring-nostroke-fill-when-contained-in-pgraphics/36508/3 "2022-04-22T08:06:14Z")

</div>

@glv – thanks for the reply. Your example demo got me in the right direction.

I had declared disableStyle() elsewhere during setup() which for some reason was not passing into the draw() PGraphics beginDraw() ~ endDraw() part of my code.

So thanks to you, I got the result I wanted via this:

```auto
void draw() {

int liveKey = int(key);
if (keyPressed && liveKey >= 97 && liveKey <= 122) { // lowercase QWERTY: 97 = key a, 122 = key z
   liveKey = liveKey - 97;
   shape = shapeGroup[liveKey];
   shape.disableStyle(); // disableStyle only works for me when declared before beginDraw() ?
      pg.beginDraw();
      pg.colorMode(RGB, 1.0);
      pg.background(0, 0, 0, 1);
      pg.fill(1, 1, 1, 1);
      pg.stroke(1, 1, 1, 1);
      pg.shape(shape);
      pg.endDraw();
      blendMode(MULTIPLY);
   image(pg, 0, 0);
}
// etc. etc.
}

```

And with this, my shapes are now rendered how I actually want.

Without declaring disableStyle() as above, the shapes would always revert to default styling no matter what code I wrote after beginDraw()

Cheers again!
