Browse Source

Fixed grid lines overlay

flabbet 9 months ago
parent
commit
624bfc2525
1 changed files with 12 additions and 11 deletions
  1. 12 11
      src/PixiEditor/Views/Overlays/GridLinesOverlay.cs

+ 12 - 11
src/PixiEditor/Views/Overlays/GridLinesOverlay.cs

@@ -2,8 +2,10 @@
 using Avalonia.Media;
 using Avalonia.Media;
 using Drawie.Backend.Core.Numerics;
 using Drawie.Backend.Core.Numerics;
 using Drawie.Backend.Core.Surfaces;
 using Drawie.Backend.Core.Surfaces;
+using Drawie.Backend.Core.Surfaces.PaintImpl;
 using PixiEditor.Helpers.Converters;
 using PixiEditor.Helpers.Converters;
 using Drawie.Numerics;
 using Drawie.Numerics;
+using Colors = Drawie.Backend.Core.ColorsImpl.Colors;
 using Point = Avalonia.Point;
 using Point = Avalonia.Point;
 
 
 namespace PixiEditor.Views.Overlays;
 namespace PixiEditor.Views.Overlays;
@@ -46,9 +48,9 @@ public class GridLinesOverlay : Overlay
         set => SetValue(RowsProperty, value);
         set => SetValue(RowsProperty, value);
     }
     }
 
 
-    private const double PenWidth = 0.8d;
-    private Pen pen1 = new(Brushes.Black, PenWidth);
-    private Pen pen2 = new(Brushes.White, PenWidth);
+    private const float PenWidth = 0.8f;
+    private Paint pen1 = new Paint() { Color = Colors.Black, StrokeWidth = PenWidth, IsAntiAliased = true, Style = PaintStyle.Stroke };
+    private Paint pen2 = new Paint() { Color = Colors.White, StrokeWidth = PenWidth, IsAntiAliased = true, Style = PaintStyle.Stroke };
     private ThresholdVisibilityConverter visibilityConverter = new(){ Threshold = 10 };
     private ThresholdVisibilityConverter visibilityConverter = new(){ Threshold = 10 };
 
 
     static GridLinesOverlay()
     static GridLinesOverlay()
@@ -70,29 +72,28 @@ public class GridLinesOverlay : Overlay
     {
     {
         // Draw lines in vertical and horizontal directions, size should be relative to the scale
         // Draw lines in vertical and horizontal directions, size should be relative to the scale
 
 
-        /*base.Render(context);
         double width = PixelWidth;
         double width = PixelWidth;
         double height = PixelHeight;
         double height = PixelHeight;
 
 
         double columnWidth = width / Columns;
         double columnWidth = width / Columns;
         double rowHeight = height / Rows;
         double rowHeight = height / Rows;
 
 
-        pen1.Thickness = ReciprocalConverter.Convert(ZoomScale);
-        pen2.Thickness = ReciprocalConverter.Convert(ZoomScale, 1.2);
+        pen1.StrokeWidth = (float)ReciprocalConverter.Convert(ZoomScale);
+        pen2.StrokeWidth = (float)ReciprocalConverter.Convert(ZoomScale, 1.2);
 
 
         for (int i = 0; i < Columns; i++)
         for (int i = 0; i < Columns; i++)
         {
         {
             double x = i * columnWidth;
             double x = i * columnWidth;
-            context.DrawLine(pen1, new Point(x, 0), new Point(x, height));
-            context.DrawLine(pen2, new Point(x, 0), new Point(x, height));
+            context.DrawLine(new VecD(x, 0), new VecD(x, height), pen1);
+            context.DrawLine(new VecD(x, 0), new VecD(x, height), pen2);
         }
         }
 
 
         for (int i = 0; i < Rows; i++)
         for (int i = 0; i < Rows; i++)
         {
         {
             double y = i * rowHeight;
             double y = i * rowHeight;
-            context.DrawLine(pen1, new Point(0, y), new Point(width, y));
-            context.DrawLine(pen2, new Point(0, y), new Point(width, y));
-        }*/
+            context.DrawLine(new VecD(0, y), new VecD(width, y), pen1);
+            context.DrawLine(new VecD(0, y), new VecD(width, y), pen2);
+        }
     }
     }
 
 
     private static void OnIsVisibleChanged(AvaloniaPropertyChangedEventArgs<bool> e)
     private static void OnIsVisibleChanged(AvaloniaPropertyChangedEventArgs<bool> e)