Skip to content

Commit f2f81f7

Browse files
Fix perfect circle constraint logic for all quadrants
Co-authored-by: RuntimeRascal <2422222+RuntimeRascal@users.noreply.github.com>
1 parent 58b65a2 commit f2f81f7

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

Src/GhostDraw/Tools/CircleTool.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,35 @@ private void UpdateCircle(Point startPoint, Point currentPoint, bool isPerfectCi
137137
{
138138
double maxDimension = Math.Max(width, height);
139139

140-
// Adjust left/top based on which direction we're dragging
141-
if (currentPoint.X < startPoint.X)
140+
// Adjust left/top based on which quadrant we're dragging to
141+
// Determine the quadrant based on current position relative to start
142+
bool isDraggingLeft = currentPoint.X < startPoint.X;
143+
bool isDraggingUp = currentPoint.Y < startPoint.Y;
144+
145+
if (isDraggingLeft && isDraggingUp)
146+
{
147+
// Top-left quadrant
148+
left = startPoint.X - maxDimension;
149+
top = startPoint.Y - maxDimension;
150+
}
151+
else if (isDraggingLeft && !isDraggingUp)
152+
{
153+
// Bottom-left quadrant
142154
left = startPoint.X - maxDimension;
143-
if (currentPoint.Y < startPoint.Y)
155+
top = startPoint.Y;
156+
}
157+
else if (!isDraggingLeft && isDraggingUp)
158+
{
159+
// Top-right quadrant
160+
left = startPoint.X;
144161
top = startPoint.Y - maxDimension;
162+
}
163+
else
164+
{
165+
// Bottom-right quadrant
166+
left = startPoint.X;
167+
top = startPoint.Y;
168+
}
145169

146170
width = maxDimension;
147171
height = maxDimension;

0 commit comments

Comments
 (0)