quadraticVertex function not working properly

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

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

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

snap-055

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

1 Like

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

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.

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.

1 Like

you are good!
works:

snap-058

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

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