CAD
This commit is contained in:
@@ -169,11 +169,22 @@ import Layout from "#layouts/layoutCAD.astro";
|
||||
const endX = snapToGrid(e.offsetX);
|
||||
const endY = snapToGrid(e.offsetY);
|
||||
|
||||
// Draw a point if the start and end are the same
|
||||
// Check if the end point is valid:
|
||||
// - Must not be the same as the start point
|
||||
// - Must be a valid grid point or the start point of the first line
|
||||
const isValidEndPoint =
|
||||
(endX !== startX || endY !== startY) &&
|
||||
((endX === firstStartPoint?.x && endY === firstStartPoint?.y) || true);
|
||||
|
||||
if (!isValidEndPoint) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If it's a point, draw a point
|
||||
if (startX === endX && startY === endY) {
|
||||
drawPoint(startX, startY);
|
||||
} else {
|
||||
// Draw the line
|
||||
// Otherwise, draw the line
|
||||
drawLine(startX, startY, endX, endY);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user