Browse Source

Update LineTool.cs

Krzysztof Krysiński 3 years ago
parent
commit
90b40f0b5c
1 changed files with 10 additions and 12 deletions
  1. 10 12
      PixiEditor/Models/Tools/Tools/LineTool.cs

+ 10 - 12
PixiEditor/Models/Tools/Tools/LineTool.cs

@@ -53,12 +53,16 @@ namespace PixiEditor.Models.Tools.Tools
             Coordinates start = coordinates[0];
             Coordinates start = coordinates[0];
             Coordinates end = coordinates[^1];
             Coordinates end = coordinates[^1];
 
 
-            int halfThickness = (int)Math.Ceiling(thickness / 2.0);
-            Int32Rect dirtyRect = new Int32Rect(
-                start.X - halfThickness,
-                start.Y - halfThickness,
-                end.X + halfThickness,
-                end.Y + halfThickness);
+            int x1 = start.X;
+            int y1 = start.Y;
+            int x = end.X;
+            int y = end.Y;
+
+            Int32Rect dirtyRect = new Int32Rect( // Idk why it sometimes doesn't add one x or y, @Equbuxu hulp
+                Math.Min(x, x1) - thickness,
+                Math.Min(y, y1) - thickness,
+                Math.Max(x1, x) + thickness, 
+                Math.Max(y1, y) + thickness);
             Int32Rect curLayerRect = new(layer.OffsetX, layer.OffsetY, layer.Width, layer.Height);
             Int32Rect curLayerRect = new(layer.OffsetX, layer.OffsetY, layer.Width, layer.Height);
             Int32Rect expanded = dirtyRect.Expand(curLayerRect);
             Int32Rect expanded = dirtyRect.Expand(curLayerRect);
 
 
@@ -66,12 +70,6 @@ namespace PixiEditor.Models.Tools.Tools
 
 
             using (SKPaint paint = new SKPaint())
             using (SKPaint paint = new SKPaint())
             {
             {
-                int x = start.X;
-                int y = start.Y;
-                int x1 = end.X;
-                int y1 = end.Y;
-
-
                 paint.StrokeWidth = thickness;
                 paint.StrokeWidth = thickness;
                 paint.Style = SKPaintStyle.StrokeAndFill;
                 paint.Style = SKPaintStyle.StrokeAndFill;
                 paint.Color = color;
                 paint.Color = color;