flabbet 2 years ago
parent
commit
6d9f2deab4

+ 3 - 7
src/PixiEditor.ChangeableDocument/Changes/Drawing/FloodFill/FloodFillHelper.cs

@@ -289,12 +289,12 @@ internal static class FloodFillHelper
             }
         }
         
-        selection = BuildContour(lines, membersToFloodFill, document);
+        selection = BuildContour(lines);
 
         return selection;
     }
 
-    private static VectorPath BuildContour(List<Line> lines, HashSet<Guid> membersToFloodFill, IReadOnlyDocument document)
+    public static VectorPath BuildContour(List<Line> lines)
     {
         VectorPath selection = new();
         Line startLine = lines[0];
@@ -377,7 +377,6 @@ internal static class FloodFillHelper
                 else
                 { 
                     AddLine(new Line(new VecI(curPos.X, curPos.Y + 1) + chunkOffset, new VecI(curPos.X, curPos.Y) + chunkOffset), lines);
-                    //AddLine(new Line(new VecI(0, 1), new(0, 0)));
                 }
             }
 
@@ -391,7 +390,6 @@ internal static class FloodFillHelper
                 else
                 {
                     AddLine(new Line(new VecI(curPos.X + 1, curPos.Y) + chunkOffset, new VecI(curPos.X + 1, curPos.Y + 1) + chunkOffset), lines);
-                    //AddLine(new Line(new VecI(1, 0), new(1, 1)));
                 }
             }
 
@@ -405,7 +403,6 @@ internal static class FloodFillHelper
                 else
                 {
                     AddLine(new Line(new VecI(curPos.X + 1, curPos.Y) + chunkOffset, new VecI(curPos.X, curPos.Y) + chunkOffset), lines);
-                    //AddLine(new Line(new VecI(1, 1), new(0, 1)));
                 }
             }
 
@@ -419,7 +416,6 @@ internal static class FloodFillHelper
                 else
                 {
                     AddLine(new Line(new VecI(curPos.X + 1, curPos.Y + 1) + chunkOffset, new VecI(curPos.X, curPos.Y + 1) + chunkOffset), lines);
-                    //AddLine(new Line(new VecI(0, 0), new(1, 0)));
                 }
             }
         }
@@ -433,7 +429,7 @@ internal static class FloodFillHelper
         lines.Add(line);
     }
 
-    private struct Line
+    public struct Line
     {
         public VecI Start { get; set; }
         public VecI End { get; set; }

+ 1 - 0
src/PixiEditor.DrawingApi.Core/Bridge/NativeObjectsImpl/IVectorPathImplementation.cs

@@ -34,6 +34,7 @@ public interface IVectorPathImplementation
     public void AddOval(VectorPath vectorPath, RectI borders);
     public VectorPath Op(VectorPath vectorPath, VectorPath ellipsePath, VectorPathOp pathOp);
     public void Close(VectorPath vectorPath);
+    public VectorPath Simplify(VectorPath vectorPath);
     public string ToSvgPathData(VectorPath vectorPath);
     public void AddPath(VectorPath vectorPath, VectorPath path, AddPathMode mode);
 }

+ 5 - 0
src/PixiEditor.DrawingApi.Core/Surface/Vector/VectorPath.cs

@@ -141,6 +141,11 @@ public class VectorPath : NativeObject
     {
         DrawingBackendApi.Current.PathImplementation.AddPath(this, path, mode);
     }
+    
+    public VectorPath Simplify()
+    {
+        return DrawingBackendApi.Current.PathImplementation.Simplify(this);
+    }
 }
 
 public enum PathDirection

+ 7 - 0
src/PixiEditor.DrawingApi.Skia/Implementations/SkiaPathImplementation.cs

@@ -161,6 +161,13 @@ namespace PixiEditor.DrawingApi.Skia.Implementations
             return new VectorPath(skPath.Handle);
         }
 
+        public VectorPath Simplify(VectorPath path)
+        {
+            SKPath skPath = ManagedInstances[path.ObjectPointer].Simplify();
+            ManagedInstances.Add(skPath.Handle, skPath);
+            return new VectorPath(skPath.Handle);
+        }
+
         public void Close(VectorPath vectorPath)
         {
             ManagedInstances[vectorPath.ObjectPointer].Close();