Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caps at beginning of curve #6817

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/webgl/p5.Geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,21 @@ p5.Geometry = class Geometry {
if (dirOK) {
this._addSegment(begin, end, fromColor, toColor, dir);
}
// Check and add cap at the start of the stroke if not connected
if (i === 0 || !connected.has(currEdge[0])) {
const capInfo = potentialCaps.get(currEdge[0]) || {
point: begin,
dir: dir.copy().mult(-1),
color: fromColor
};
this._addCap(capInfo.point, capInfo.dir, capInfo.color);
potentialCaps.delete(currEdge[0]);
connected.add(currEdge[0]);
}else {
// If the vertex is already connected, remove its potential cap
potentialCaps.delete(currEdge[0]);
}


if (i > 0 && prevEdge[1] === currEdge[0]) {
if (!connected.has(currEdge[0])) {
Expand Down
Loading