Browse Source

Organize a bit more

Equbuxu 2 years ago
parent
commit
5c1d18b1c6

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

@@ -18,7 +18,7 @@ public static class FloodFillHelper
     private static readonly VecI Left = new VecI(-1, 0);
     private static readonly VecI Right = new VecI(1, 0);
 
-    private static FloodFillChunkCache CreateCache(HashSet<Guid> membersToFloodFill, IReadOnlyDocument document)
+    internal static FloodFillChunkCache CreateCache(HashSet<Guid> membersToFloodFill, IReadOnlyDocument document)
     {
         if (membersToFloodFill.Count == 1)
         {

+ 1 - 15
src/PixiEditor.ChangeableDocument/Changes/Selection/MagicWand/MagicWandHelper.cs

@@ -9,7 +9,6 @@ using PixiEditor.DrawingApi.Core.Surface.Vector;
 namespace PixiEditor.ChangeableDocument.Changes.Selection.MagicWand;
 internal class MagicWandHelper
 {
-    private const byte InSelection = 1;
     private const byte Visited = 2;
 
     private static readonly VecI Up = new VecI(0, -1);
@@ -19,19 +18,6 @@ internal class MagicWandHelper
 
     private static MagicWandVisualizer visualizer = new MagicWandVisualizer(Path.Combine("Debugging", "MagicWand"));
 
-    private static FloodFillChunkCache CreateCache(HashSet<Guid> membersToFloodFill, IReadOnlyDocument document)
-    {
-        if (membersToFloodFill.Count == 1)
-        {
-            Guid guid = membersToFloodFill.First();
-            var member = document.FindMemberOrThrow(guid);
-            if (member is IReadOnlyFolder folder)
-                return new FloodFillChunkCache(membersToFloodFill, document.StructureRoot);
-            return new FloodFillChunkCache(((IReadOnlyLayer)member).LayerImage);
-        }
-        return new FloodFillChunkCache(membersToFloodFill, document.StructureRoot);
-    }
-
     public static VectorPath GetFloodFillSelection(VecI startingPos, HashSet<Guid> membersToFloodFill,
         IReadOnlyDocument document)
     {
@@ -40,7 +26,7 @@ internal class MagicWandHelper
 
         int chunkSize = ChunkResolution.Full.PixelSize();
 
-        FloodFillChunkCache cache = CreateCache(membersToFloodFill, document);
+        FloodFillChunkCache cache = FloodFillHelper.CreateCache(membersToFloodFill, document);
 
         VecI initChunkPos = OperationHelper.GetChunkPos(startingPos, chunkSize);
         VecI imageSizeInChunks = (VecI)(document.Size / (double)chunkSize).Ceiling();