Browse Source

Fixed constant value of combine color using values from 0 - 255

CPKreuz 11 months ago
parent
commit
b5c78b6e1e

+ 5 - 5
src/PixiEditor.ChangeableDocument/Changeables/Graph/Context/FuncContext.cs

@@ -98,10 +98,10 @@ public class FuncContext
         if (!HasContext && r is Float1 firstFloat && g is Float1 secondFloat && b is Float1 thirdFloat && a is Float1 fourthFloat)
         {
             Half4 constantHalf4 = new Half4("");
-            byte rByte = (byte)firstFloat.ConstantValue;
-            byte gByte = (byte)secondFloat.ConstantValue;
-            byte bByte = (byte)thirdFloat.ConstantValue;
-            byte aByte = (byte)fourthFloat.ConstantValue;
+            byte rByte = firstFloat.FullSizeByteConstant;
+            byte gByte = secondFloat.FullSizeByteConstant;
+            byte bByte = thirdFloat.FullSizeByteConstant;
+            byte aByte = fourthFloat.FullSizeByteConstant;
             constantHalf4.ConstantValue = new Color(rByte, gByte, bByte, aByte);
             return constantHalf4;
         }
@@ -117,7 +117,7 @@ public class FuncContext
             var hValue = firstFloat.ConstantValue * 360;
             var sValue = secondFloat.ConstantValue * 100;
             var lValue = thirdFloat.ConstantValue * 100;
-            byte aByte = (byte)(fourthFloat.ConstantValue * 255);
+            byte aByte = fourthFloat.FullSizeByteConstant;
             constantHalf4.ConstantValue = Color.FromHsl((float)hValue, (float)sValue, (float)lValue, aByte);
             return constantHalf4;
         }

+ 2 - 1
src/PixiEditor.DrawingApi.Core/Shaders/Generation/Expressions/Float1.cs

@@ -15,5 +15,6 @@ public class Float1(string name) : ShaderExpressionVariable<double>(name)
     public static implicit operator Float1(double value) => new Float1("") { ConstantValue = value };
 
     public static explicit operator double(Float1 value) => value.ConstantValue;
-    
+
+    public byte FullSizeByteConstant => (byte)(ConstantValue * 255);
 }