diff --git a/line-segment-intersection/src/App.svelte b/line-segment-intersection/src/App.svelte index 7193edc..a3d7ee9 100644 --- a/line-segment-intersection/src/App.svelte +++ b/line-segment-intersection/src/App.svelte @@ -8,7 +8,6 @@ const HEIGHT = 320; let userPoint = { x: 5, y: 2 }; - let trackHover = true; // Rectangle coordinates const blueRect = { x1: 6, y1: 1 }; // Blue rectangle corner @@ -62,33 +61,16 @@ ctx.stroke(); } - function handleMouseMove(event) { - if (!trackHover) return; - - const rect = canvas.getBoundingClientRect(); - const mouseX = event.clientX - rect.left; - const mouseY = event.clientY - rect.top; - - // Add half grid unit offset for snapping to closest grid intersection - userPoint = { - x: Math.floor((mouseX + GRID_SIZE / 2) / GRID_SIZE), - y: Math.floor((HEIGHT - mouseY + GRID_SIZE / 2) / GRID_SIZE) - }; - } - function handleCanvasClick(event) { - // Update position at click location before toggling tracking const rect = canvas.getBoundingClientRect(); const mouseX = event.clientX - rect.left; const mouseY = event.clientY - rect.top; - // Add half grid unit offset for snapping to closest grid intersection + // Snap to closest grid intersection userPoint = { x: Math.floor((mouseX + GRID_SIZE / 2) / GRID_SIZE), y: Math.floor((HEIGHT - mouseY + GRID_SIZE / 2) / GRID_SIZE) }; - - trackHover = !trackHover; } function toCanvasCoords(x, y) { @@ -223,7 +205,7 @@

Line Segment Intersection

- +