diff --git a/Minint/Controls/PixelCanvas.cs b/Minint/Controls/PixelCanvas.cs index b9b2e0d..07cdcad 100644 --- a/Minint/Controls/PixelCanvas.cs +++ b/Minint/Controls/PixelCanvas.cs @@ -125,7 +125,7 @@ public class PixelCanvas : Control RenderOptions.SetBitmapInterpolationMode(this, BitmapInterpolationMode.None); context.DrawImage(bmp, srcRect, destRect); - if (ShowGrid && _viewport.Zoom >= 4) + if (ShowGrid) DrawPixelGrid(context, imgW, imgH); DrawToolPreview(context, imgW, imgH); @@ -167,7 +167,11 @@ public class PixelCanvas : Control private void DrawPixelGrid(DrawingContext context, int imgW, int imgH) { - var pen = new Pen(new SolidColorBrush(Color.FromArgb(60, 255, 255, 255)), 1); + double zoom = _viewport.Zoom; + if (zoom < 4) return; + + var pen = new Pen(Brushes.Black, 1); + var clip = new Rect(0, 0, Bounds.Width, Bounds.Height); var imgRect = _viewport.ImageScreenRect(imgW, imgH); var visible = imgRect.Intersect(clip); @@ -185,12 +189,14 @@ public class PixelCanvas : Control for (int px = startPx; px <= endPx; px++) { var (sx, _) = _viewport.PixelToScreen(px, 0); - context.DrawLine(pen, new Point(sx, visible.Top), new Point(sx, visible.Bottom)); + double x = Math.Floor(sx) + 0.5; + context.DrawLine(pen, new Point(x, visible.Top), new Point(x, visible.Bottom)); } for (int py = startPy; py <= endPy; py++) { var (_, sy) = _viewport.PixelToScreen(0, py); - context.DrawLine(pen, new Point(visible.Left, sy), new Point(visible.Right, sy)); + double y = Math.Floor(sy) + 0.5; + context.DrawLine(pen, new Point(visible.Left, y), new Point(visible.Right, y)); } } } diff --git a/Minint/Views/MainWindow.axaml b/Minint/Views/MainWindow.axaml index ba332d1..4de0f0b 100644 --- a/Minint/Views/MainWindow.axaml +++ b/Minint/Views/MainWindow.axaml @@ -45,7 +45,7 @@ + IsChecked="{Binding Editor.ShowGrid, Mode=TwoWay}" HotKey="Ctrl+G"/>