About custom shapes (using beginShape function) with a stroke in p5.js WEBGL Mode: In WEBGL Mode the lineJoint() and lineCap() functions are not available. This is why the lines in a shape don't connect seamlessly. I tried to work around the problem using a contour in my custom shape but this is not implemented in WEBGL Mode either.
Is there another way to make those lines join?
Thanks a lot!
Codepen with Problem: https://codepen.io/sebastianwinter/pen/eYNNEEx?editors=1010
Not working Contour
function setup() {
createCanvas(window.innerWidth, window.innerHeight, WEBGL);
}
function draw() {
let strokeSize = 20;
background(2,8,51);
smooth();
noFill();
strokeWeight(strokeSize);
stroke(255,255,255);
polygon(0, 0, 200, 7);
}
function polygon(x, y, radius, npoints) {
let angle = TWO_PI / npoints;
beginShape();
for (let a = 0; a < TWO_PI; a += angle) {
let sx = x + cos(a) * radius;
let sy = y + sin(a) * radius;
vertex(sx, sy);
}
/* not working:
beginContour();
for (let a = 0; a < TWO_PI; a += angle) {
let sx = x + cos(a) * (radius - strokeSize);
let sy = y + sin(a) * (radius - strokeSize);
vertex(sx, sy);
}
endContour();*/
endShape(CLOSE);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.10.2/p5.js"></script>