Skip to content

Commit 9c6ae95

Browse files
committed
feat: clamp anchor point position to hue wheel boundaries
1 parent fb3f48c commit 9c6ae95

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

dist/index.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2714,7 +2714,18 @@ <h2 class="export__title">${paletteTitle}</h2>
27142714
}
27152715

27162716
if (e.key === 'p') {
2717-
lastSelectedPoint = poline.addAnchorPoint({xyz: [lastX, lastY, lastY]});
2717+
// Clamp position to be within the hue wheel (circle with radius 0.5 centered at 0.5, 0.5)
2718+
let px = lastX;
2719+
let py = lastY;
2720+
const dx = px - 0.5;
2721+
const dy = py - 0.5;
2722+
const dist = Math.hypot(dx, dy);
2723+
if (dist > 0.5) {
2724+
// Project to edge of circle
2725+
px = 0.5 + (dx / dist) * 0.5;
2726+
py = 0.5 + (dy / dist) * 0.5;
2727+
}
2728+
lastSelectedPoint = poline.addAnchorPoint({xyz: [px, py, py]});
27182729
updateSVG();
27192730
updateFullCode();
27202731
}

0 commit comments

Comments
 (0)