# quadraticVertex function not working properly

**URL:** https://discourse.processing.org/t/quadraticvertex-function-not-working-properly/4938
**Category:** Coding Questions
**Created:** [October 28, 2018, 2:12am UTC](https://discourse.processing.org/t/quadraticvertex-function-not-working-properly/4938 "2018-10-28T02:12:24Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![cbroney](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@cbroney](https://discourse.processing.org/u/cbroney)
#### Post date: [October 28, 2018, 2:12am UTC](https://discourse.processing.org/t/quadraticvertex-function-not-working-properly/4938/1 "2018-10-28T02:12:24Z")

</div>

when I load this shape i created it doesnt draw with the curves unless I remove the “b1” from each line. can someone please tell me why

```auto
PShape b1;
PShape b2;
PShape b3;

void setup() {
  size(1600,1200);
  background(255);
  b1 = createShape();
  b1.beginShape();
  b1.fill(0,0,255);
  b1.vertex(200, 100);
  b1.vertex(300, 100);
  b1.quadraticVertex(310, 110, 300, 125);
  b1.vertex(300, 400);
  b1.quadraticVertex(500, 400, 400, 800);
  b1.vertex(100, 800);
  b1.quadraticVertex(25, 400, 200, 400);
  b1.vertex(200, 125);
  b1.quadraticVertex(190, 115, 200, 100); 
  b1.endShape();
}

void draw() {
  shape(b1,25,25);  
}

```

---

<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: [October 28, 2018, 4:21am UTC](https://discourse.processing.org/t/quadraticvertex-function-not-working-properly/4938/2 "2018-10-28T04:21:16Z")

</div>

sorry, no idea, but i think i could recreate your situation:

![snap-055](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/859343fd49ee13546238d598bb3a5a01050cdb59.jpeg)

```auto
PShape b1;

void create_b0() {
  beginShape();
  fill(0, 255, 255);
  vertex(30, 40);
  quadraticVertex(50, 40, 40, 80);
  endShape(CLOSE);
}

void create_b1() { // float big) {
  b1 = createShape();
  //b1.scale(big);
  //b1.rotate(PI/4);
  b1.beginShape();
  b1.fill(255, 0, 255);
  b1.vertex(30, 40);
  b1.quadraticVertex(50, 40, 40, 80);
  b1.endShape(CLOSE);
}

void setup() {
  size(160, 120);
  background(0, 100, 100);
  create_b0();
  create_b1(); // 1.3); 
  shape(b1, 50, 10);

}

void draw() {
}

```

![snap-057](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/794a23cf68cfa9c89cc9629adf2bfda585538cf0.jpeg)

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [October 31, 2018, 5:21pm UTC](https://discourse.processing.org/t/quadraticvertex-function-not-working-properly/4938/3 "2018-10-31T17:21:48Z")

</div>

Could you please post your test code for this, as well as the screenshot?

---

<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: [November 1, 2018, 12:20am UTC](https://discourse.processing.org/t/quadraticvertex-function-not-working-properly/4938/4 "2018-11-01T00:20:54Z")

</div>

see above,  
sorry i play with it more…  
but i started with OP’s original code,  
smaller by change 1 / 10  
delete lines until i only had one

> quadraticVertex

but still same effect.

is it possible that the

> createShape

is doing some secret initial MODE thing?  
i try to find MODE about this but failed.

the question was not to find a other  
vertex function that would work for the OP,  
just the question why createShape does it differently.

---

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [November 1, 2018, 1:41am UTC](https://discourse.processing.org/t/quadraticvertex-function-not-working-properly/4938/5 "2018-11-01T01:41:27Z")

</div>

You need to add P2D in the size() method.

Edit: I’m not too sure why this is the case, but i assume it has something to do with the difference in drawing a PShape and just drawing it directly. Probably the curves take P2D in the PShape, but for the canvas itself, this might be handeled differently… And since the P2D is not set, in the PShape the methods behind quadraticVertex() are missing an information, and thus won’t be set at all.

---

<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: [November 1, 2018, 1:55am UTC](https://discourse.processing.org/t/quadraticvertex-function-not-working-properly/4938/6 "2018-11-01T01:55:13Z")

</div>

you are good!  
works:

![snap-058](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5af4b29f78ad817b043e24d1a9ae63c08d391ea0.jpeg)

but now i even got more confused:  
what is the “quadratic” on that what we see?  
LOL

---

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [November 1, 2018, 1:59am UTC](https://discourse.processing.org/t/quadraticvertex-function-not-working-properly/4938/7 "2018-11-01T01:59:45Z")

</div>

Do you mean why it’s called quadratic? Probably because it takes 4 vectors… or it does quadratic calculation… Not sure 😅
