Browse Source

Moved BuildInFunctionType in BuildInFunctions.cs

CPKreuz 11 months ago
parent
commit
838c8609f5

+ 0 - 10
src/PixiEditor.DrawingApi.Core/Shaders/Generation/BuiltInFunctionType.cs

@@ -1,10 +0,0 @@
-namespace PixiEditor.DrawingApi.Core.Shaders.Generation;
-
-public enum BuiltInFunctionType
-{
-    HueToRgb,
-    RgbToHsl,
-    HslToRgb,
-    RgbToHsv,
-    HsvToRgb
-}

+ 25 - 16
src/PixiEditor.DrawingApi.Core/Shaders/Generation/BuiltInFunctions.cs

@@ -20,21 +20,6 @@ public class BuiltInFunctions
     public Expression GetHslToRgb(Expression h, Expression s, Expression l, Expression a) =>
         GetHslToRgb(Half4.Constructor(h, s, l, a));
     
-    private void Require(BuiltInFunctionType type)
-    {
-        if (usedFunctions.Contains(type))
-        {
-            return;
-        }
-
-        if (type is BuiltInFunctionType.HslToRgb)
-        {
-            Require(BuiltInFunctionType.HueToRgb);
-        }
-            
-        usedFunctions.Add(type);
-    }
-
     public string BuildFunctions()
     {
         var builder = new StringBuilder();
@@ -52,7 +37,22 @@ public class BuiltInFunctions
             }
         }
     }
-    
+
+    private void Require(BuiltInFunctionType type)
+    {
+        if (usedFunctions.Contains(type))
+        {
+            return;
+        }
+
+        if (type is BuiltInFunctionType.HslToRgb)
+        {
+            Require(BuiltInFunctionType.HueToRgb);
+        }
+            
+        usedFunctions.Add(type);
+    }
+
     // Taken from here https://www.shadertoy.com/view/4dKcWK
     private const string HueToRgb =
         $$"""
@@ -96,4 +96,13 @@ public class BuiltInFunctions
     //         return half4(hcv.x, s, z, rgba.w);
     //     }
     //     """;
+    
+    enum BuiltInFunctionType
+    {
+        HueToRgb,
+        RgbToHsl,
+        HslToRgb,
+        RgbToHsv,
+        HsvToRgb
+    }
 }