mkoch
April 11, 2019, 7:47am
1
Hello everyone,
I have a problem using the beginContour and endContour methods with curve vertices.
The contour is not rendered like expected.
Here I’ve got a simple example of the problem
https://editor.p5js.org/mkoch/sketches/c-OXrym1D
As you can see in the example, the interior lines of the shape are connected to the exterior lines when using curveVertex within the beginContour - endContour pair.
kll
April 11, 2019, 9:39am
2
i not play with contour…
but for the
curveVertex
-a- must close the curve manually
( 4 corners are 5 curveVertex points where the last same the first )
and then not even need the CLOSE.
and as the reference says
need to define 2 add vertex points
control points
for the start angle
so actually you go 1.5 times around your shape ( 7 points )
and it works
use
let w = 40;
function setup() {
createCanvas(400, 400);
}
function draw() {
translate(100, 100);
w = 40;
beginShape();
curveVertex(-w, w);
curveVertex(-w, -w);
curveVertex(w, -w);
curveVertex(w, w);
curveVertex(-w, w);
curveVertex(-w, -w);
curveVertex(w, -w);
endShape();
w = 20;
beginShape();
curveVertex(-w, w);
curveVertex(-w, -w);
curveVertex(w, -w);
curveVertex(w, w);
curveVertex(-w, w);
curveVertex(-w, -w);
curveVertex(w, -w);
endShape();
}
A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.
more about control points
A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.