# Shape function draws nothing when given width and height

**URL:** <https://discourse.processing.org/t/shape-function-draws-nothing-when-given-width-and-height/7877>\
**Category:** Coding Questions\
**Created:** [January 27, 2019, 2:05pm UTC](https://discourse.processing.org/t/shape-function-draws-nothing-when-given-width-and-height/7877 "2019-01-27T14:05:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![resbot](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@resbot](https://discourse.processing.org/u/resbot)\
**Post date:** [January 27, 2019, 2:05pm UTC](https://discourse.processing.org/t/shape-function-draws-nothing-when-given-width-and-height/7877/1 "2019-01-27T14:05:30Z")

</div>

I am defining a custom PShape and attempting to redraw it a variable sizes.  
When I simply use the command shape(shapename, x, y) it draws correctly.  
When I use shape(shapename, a, b, c, d) where c and d are the width and height, it draws nothing. Anyone know why?

Here is my example code:

```auto
PShape myshape;
void setup(){
  size(500,500);
  myshape = createShape(GROUP);
  PShape rct,tri;
  rct = createShape(RECT,0,0,32,64);
  rct.setStroke(color(0,185,0));
  rct.setFill(color(0,120,0));
  tri = createShape();
  tri.beginShape();
  tri.fill(0,255,0);
  tri.stroke(0,200,0);
  tri.vertex(4, 4);
  tri.vertex(28, 32);
  tri.vertex(4, 60);
  tri.vertex(4, 2);
  tri.endShape();
  myshape.addChild(rct);
  myshape.addChild(tri);
  shape(myshape,125,250);
  shape(myshape,375,250,20,50);
}

```

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 27, 2019, 2:13pm UTC](https://discourse.processing.org/t/shape-function-draws-nothing-when-given-width-and-height/7877/2 "2019-01-27T14:13:43Z")

</div>

pls format your code with the

```auto
</>

```

code formatter.

when i try your code i see something?

 ![2019-01-27_21-12-01_snap](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/ba65c326e2226a94870fbbfc64e1212310889a1f.png)  
and what did you expect? oh yes,  
the second one i only see with

```auto
PShape myshape;
PShape rct, tri;

void setup() {
  size(500, 500,P2D);
  myshape = createShape(GROUP);
  rct = createShape(RECT, 0, 0, 32, 64);
  rct.setStroke(color(0, 185, 0));
  rct.setFill(color(0, 120, 0));
  tri = createShape();
  tri.beginShape();
  tri.fill(0, 255, 0);
  tri.stroke(0, 200, 0);
  tri.vertex(4, 4);
  tri.vertex(28, 32);
  tri.vertex(4, 60);
  tri.vertex(4, 2);
  tri.endShape();
  myshape.addChild(rct);
  myshape.addChild(tri);
}
void draw() {
  background(200, 200, 0);
  shape(myshape, 125, 250);
  shape(myshape, 375,250,20,50);
}

```

---

<div class="post-metadata">

**Author:** ![resbot](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@resbot](https://discourse.processing.org/u/resbot)\
**Post date:** [January 27, 2019, 2:37pm UTC](https://discourse.processing.org/t/shape-function-draws-nothing-when-given-width-and-height/7877/3 "2019-01-27T14:37:16Z")

</div>

Thanks for responding, my first time posting here and I wasn’t sure how to use the code formatting.

So your version works because you employed the P2D renderer in the size() function. I guess the default renderer can’t display it correctly. Hmm, oh well. Thanks!
