Browse Source

Fixed pixel perfect erasing not working

Krzysztof Krysiński 2 months ago
parent
commit
ea550b39fd

+ 2 - 1
src/PixiEditor/Data/Configs/ToolSetsConfig.json

@@ -60,7 +60,8 @@
           "ExposeHardness": true,
           "ExposeHardness": true,
           "ExposeSpacing": true,
           "ExposeSpacing": true,
           "BrushShapeSetting": "CircleSmooth",
           "BrushShapeSetting": "CircleSmooth",
-          "PaintShape": "Circle"
+          "PaintShape": "Circle",
+          "PixelPerfectEnabled": false
         }
         }
       },
       },
       "Select",
       "Select",

+ 1 - 1
src/PixiEditor/Models/DocumentModels/UpdateableChangeExecutors/EraserToolExecutor.cs

@@ -50,7 +50,7 @@ internal class EraserToolExecutor : UpdateableChangeExecutor
         spacing = toolbar.Spacing;
         spacing = toolbar.Spacing;
 
 
         colorsHandler.AddSwatch(new PaletteColor(color.R, color.G, color.B));
         colorsHandler.AddSwatch(new PaletteColor(color.R, color.G, color.B));
-        IAction? action = new LineBasedPen_Action(guidValue, Colors.White, controller!.LastPixelPosition, (float)toolSize, true,
+        IAction? action = new LineBasedPen_Action(guidValue, Colors.White, controller!.LastPixelPosition, (float)eraserTool.ToolSize, true,
             antiAliasing, hardness, spacing, SquareBrush, drawOnMask, document!.AnimationHandler.ActiveFrameBindable);
             antiAliasing, hardness, spacing, SquareBrush, drawOnMask, document!.AnimationHandler.ActiveFrameBindable);
         internals!.ActionAccumulator.AddActions(action);
         internals!.ActionAccumulator.AddActions(action);
 
 

+ 1 - 1
src/PixiEditor/Models/Handlers/Tools/IEraserToolHandler.cs

@@ -2,5 +2,5 @@
 
 
 internal interface IEraserToolHandler : IToolHandler
 internal interface IEraserToolHandler : IToolHandler
 {
 {
-
+    public double ToolSize { get; }
 }
 }

+ 1 - 1
src/PixiEditor/ViewModels/SubViewModels/IoViewModel.cs

@@ -305,7 +305,7 @@ internal class IoViewModel : SubViewModel<ViewModelMain>
             var toolSize = eraserTool.Toolbar.Settings.First(x => x.Name == "ToolSize");
             var toolSize = eraserTool.Toolbar.Settings.First(x => x.Name == "ToolSize");
             previousEraseSize = (double)toolSize.Value;
             previousEraseSize = (double)toolSize.Value;
             toolSize.Value = tools.ActiveTool is PenToolViewModel { PixelPerfectEnabled: true }
             toolSize.Value = tools.ActiveTool is PenToolViewModel { PixelPerfectEnabled: true }
-                ? 1
+                ? 1d
                 : currentToolSize.Value;
                 : currentToolSize.Value;
         }
         }
         else
         else

+ 1 - 1
src/PixiEditor/ViewModels/Tools/Tools/EraserToolViewModel.cs

@@ -22,7 +22,7 @@ internal class EraserToolViewModel : ToolViewModel, IEraserToolHandler
         Toolbar = ToolbarFactory.Create<EraserToolViewModel, PenToolbar>(this);
         Toolbar = ToolbarFactory.Create<EraserToolViewModel, PenToolbar>(this);
     }
     }
 
 
-    [Settings.Inherited] public double ToolSize => GetValue<int>();
+    [Settings.Inherited] public double ToolSize => GetValue<double>();
 
 
     public override bool IsErasable => true;
     public override bool IsErasable => true;
 
 

+ 1 - 1
src/PixiEditor/ViewModels/Tools/Tools/PenToolViewModel.cs

@@ -139,7 +139,7 @@ namespace PixiEditor.ViewModels.Tools.Tools
                 if (PixelPerfectEnabled)
                 if (PixelPerfectEnabled)
                 {
                 {
                     actualToolSize = ToolSize;
                     actualToolSize = ToolSize;
-                    sizeSettingViewModel.Value = 1;
+                    sizeSettingViewModel.Value = 1d;
                 }
                 }
                 else
                 else
                 {
                 {