Browse Source

Fixed stabilizer for eraser

Krzysztof Krysiński 6 days ago
parent
commit
889b0e492f

+ 3 - 1
src/PixiEditor/Data/Localization/Languages/en.json

@@ -1288,5 +1288,7 @@
   "TARGET_BLEND_MODE": "Target",
   "LAST_APPLIED_POINT": "Last Applied Point",
   "VIEWPORT_INFO_NODE": "Viewport Info",
-  "EQUALS_NODE": "Equals"
+  "EQUALS_NODE": "Equals",
+  "IS_LEFT_BUTTON_PRESSED": "Is Left Button Pressed",
+  "IS_RIGHT_BUTTON_PRESSED": "Is Right Button Pressed"
 }

+ 2 - 2
src/PixiEditor/Models/DocumentModels/UpdateableChangeExecutors/BrushBasedExecutor.cs

@@ -138,7 +138,7 @@ internal class BrushBasedExecutor : UpdateableChangeExecutor
         return controller.LastPrecisePosition;
     }
 
-    private VecD GetStabilizedPointTimeBased()
+    protected VecD GetStabilizedPointTimeBased()
     {
         float timeConstant = (float)BrushToolbar.Stabilization / 100f;
         float elapsed = Math.Min((float)(DateTime.Now - lastTime).TotalSeconds, 0.1f);
@@ -150,7 +150,7 @@ internal class BrushBasedExecutor : UpdateableChangeExecutor
         return smoothed;
     }
 
-    private VecD GetStabilizedPointCircleRope(double viewportZoom)
+    protected VecD GetStabilizedPointCircleRope(double viewportZoom)
     {
         float radius = (float)BrushToolbar.Stabilization / (float)viewportZoom;
         VecD direction = controller.LastPrecisePosition - lastSmoothed;

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

@@ -20,9 +20,16 @@ internal class EraserToolExecutor : BrushBasedExecutor<IEraserToolHandler>
 {
     protected override void EnqueueDrawActions()
     {
+        var point = GetStabilizedPoint();
+
+        if (handler != null)
+        {
+            handler.LastAppliedPoint = point;
+        }
+
         Color primaryColor = controller.EditorData.PrimaryColor.WithAlpha(0);
         EditorData data = new EditorData(primaryColor, controller.EditorData.SecondaryColor);
-        var action = new LineBasedPen_Action(layerId, controller.LastPixelPosition, (float)ToolSize, antiAliasing,
+        var action = new LineBasedPen_Action(layerId, point, (float)ToolSize, antiAliasing,
             BrushData, drawOnMask,
             document!.AnimationHandler.ActiveFrameBindable, controller.LastPointerInfo, controller.LastKeyboardInfo, data);