Most appropriate sub-area of p5.js?
p5.js version
main branch
Web browser and version
Firefox 114
Operating System
MacOS 12.5.1
Steps to reproduce this
Steps:
- Set
noStroke()
- Build some geometry using
buildGeometry()
- Set
stroke(0)
- Draw the geometry with
model()
You end up with the fill triangles getting strokes rather than the contours passed in between beginShape() and endShape().
I'm not 100% sure if this should be considered a bug or not, but the result feels unexpected enough that I'm leaning towards treating it like one? Fixing this would mean always storing stroke info to p5.Geometry being built even if there is currently no stroke set, since one can add one back later, although this could lower performance when building the geometry. Maybe that's OK though since building geometry is a one-time upfront cost?
Snippet:
let geom
function setup() {
createCanvas(300, 300, WEBGL);
// Comment this out to make it work
noStroke()
geom = buildGeometry(() => {
beginShape()
for (let i = 0; i < 10; i++) {
const angle = i/10 * TWO_PI
vertex(100*cos(angle), 100*sin(angle))
}
beginContour()
for (let i = 0; i < 10; i++) {
const angle = -i/10 * TWO_PI
vertex(20*cos(angle), 20*sin(angle))
}
endContour()
endShape(CLOSE)
})
}
function draw() {
background('red')
fill('white')
stroke('black')
model(geom)
}
With noStroke() before buildGeometry():

With a stroke in buildGeometry():

Most appropriate sub-area of p5.js?
p5.js version
main branch
Web browser and version
Firefox 114
Operating System
MacOS 12.5.1
Steps to reproduce this
Steps:
noStroke()buildGeometry()stroke(0)model()You end up with the fill triangles getting strokes rather than the contours passed in between
beginShape()andendShape().I'm not 100% sure if this should be considered a bug or not, but the result feels unexpected enough that I'm leaning towards treating it like one? Fixing this would mean always storing stroke info to p5.Geometry being built even if there is currently no stroke set, since one can add one back later, although this could lower performance when building the geometry. Maybe that's OK though since building geometry is a one-time upfront cost?
Snippet:
With

noStroke()beforebuildGeometry():With a stroke in

buildGeometry():