fix: Correct background grid rendering at high zoom levels
- Fix grid line coordinate transformation (world to screen) - Properly align grid with zoom and pan transformations - Calculate grid start position at GRID_SIZE multiples - Draw grid lines across entire visible canvas area - Ensure grid lines render completely regardless of zoom level - Grid now displays consistently at all zoom magnifications Fixes: Grid no longer disappears or renders incompletely when zoomed in 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -72,20 +72,31 @@ namespace AGVNavigationCore.Controls
|
||||
|
||||
if (gridSize < 5) return; // 너무 작으면 그리지 않음
|
||||
|
||||
for (int x = bounds.Left; x < bounds.Right; x += GRID_SIZE)
|
||||
// 그리드 시작 위치 (월드 좌표에서 GRID_SIZE의 배수 찾기)
|
||||
int startX = (bounds.Left / GRID_SIZE) * GRID_SIZE;
|
||||
int startY = (bounds.Top / GRID_SIZE) * GRID_SIZE;
|
||||
|
||||
// 월드 좌표로 그리드 라인 계산
|
||||
for (int x = startX; x <= bounds.Right; x += GRID_SIZE)
|
||||
{
|
||||
// 월드 좌표를 스크린 좌표로 변환
|
||||
int screenX = x * (int)_zoomFactor + _panOffset.X;
|
||||
|
||||
if (x % (GRID_SIZE * 5) == 0)
|
||||
g.DrawLine(new Pen(Color.Gray, 1), x, bounds.Top, x, bounds.Bottom);
|
||||
g.DrawLine(new Pen(Color.Gray, 1), screenX, 0, screenX, Height);
|
||||
else
|
||||
g.DrawLine(_gridPen, x, bounds.Top, x, bounds.Bottom);
|
||||
g.DrawLine(_gridPen, screenX, 0, screenX, Height);
|
||||
}
|
||||
|
||||
for (int y = bounds.Top; y < bounds.Bottom; y += GRID_SIZE)
|
||||
for (int y = startY; y <= bounds.Bottom; y += GRID_SIZE)
|
||||
{
|
||||
// 월드 좌표를 스크린 좌표로 변환
|
||||
int screenY = y * (int)_zoomFactor + _panOffset.Y;
|
||||
|
||||
if (y % (GRID_SIZE * 5) == 0)
|
||||
g.DrawLine(new Pen(Color.Gray, 1), bounds.Left, y, bounds.Right, y);
|
||||
g.DrawLine(new Pen(Color.Gray, 1), 0, screenY, Width, screenY);
|
||||
else
|
||||
g.DrawLine(_gridPen, bounds.Left, y, bounds.Right, y);
|
||||
g.DrawLine(_gridPen, 0, screenY, Width, screenY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user