When I was exploring bezier curves. I realized that these two lines of code:
detail = 2 * int(map(mouseY, 0, height, 1, division * 5));
bezierDetail(detail);
works perfectly when I define bezier curve through bezier() function but not work within bezierVertext(), anyone have any idea?
please note: This function is only useful when using the P2D or P3D renderer; the default (JAVA2D) renderer does not use this information.
Otherwise, I don’t know why you have this.
Maybe curveVertex doesn’t use bezierVertex
Hello @unfootbird,
No idea! I would have to explore source code but not inclined to do so.
I explored this with examples below.
bezierDetail()
in Processing Java works with bezier()
and bezierVertex()
:
void setup() {
size(400, 400, P2D);
}
void draw()
{
background(220);
//translate(-width/2, -height/2);
strokeWeight(2);
int detail = 2* (int)(map(mouseY, 0, height, 1, 20));
bezierDetail(detail);
println(detail);
noFill();
beginShape();
//bezierDetail(detail); // Just testing!
vertex(30, 20);
bezierVertex(580, 200, 180, 175, 130, 175);
endShape();
translate(0, height/2);
bezier(30, 20, 580, 200, 180, 175, 130, 175);
}
bezierDetail()
in P5.js works with bezier()
but does not work with bezierVertex()
:
function setup() {
createCanvas(400, 400, WEBGL);
}
function draw()
{
background(220);
translate(-width/2, -height/2);
let detail = 2 * (int)(map(mouseY, 0, height, 1, 20));
bezierDetail(detail);
console.log(detail);
noFill();
beginShape();
//bezierDetail(detail); // Just testing!
vertex(30, 20);
bezierVertex(580, 200, 180, 175, 130, 175);
endShape();
translate(0, height/2);
bezier(30, 20, 580, 200, 180, 175, 130, 175);
}
Processing Java references:
Reference / Processing.org
P5.js references:
reference | p5.js
:)
bezierDetail()
Note, This function is only useful when using the WEBGL renderer as the default canvas renderer does not use this information.
I did similar work as you did, bezierDetail() did nothing within the scope of beginShape() and endShape()