diff --git a/LuaScript/Compat/BlendModeMap.cs b/LuaScript/Compat/BlendModeMap.cs new file mode 100644 index 0000000..25b6d7d --- /dev/null +++ b/LuaScript/Compat/BlendModeMap.cs @@ -0,0 +1,53 @@ +using YukkuriMovieMaker.Project; + +namespace LuaScript.Compat +{ + internal static class BlendModeMap + { + private static readonly Blend[] Order = + [ + Blend.Normal, + Blend.Dissolve, + Blend.Darker, + Blend.Multiply, + Blend.ColorBurn, + Blend.LinearBurn, + Blend.Lighter, + Blend.Screen, + Blend.ColorDodge, + Blend.LinearDodge, + Blend.Add, + Blend.Overlay, + Blend.SoftLight, + Blend.HardLight, + Blend.VividLight, + Blend.LinearLight, + Blend.PinLight, + Blend.HardMix, + Blend.Difference, + Blend.Exclusion, + Blend.Subtract, + Blend.Division, + Blend.Hue, + Blend.Saturation, + Blend.Color, + Blend.Luminosity, + Blend.LighterColor, + Blend.DestinationOver, + Blend.DarkerColor, + Blend.DestinationOut, + Blend.SourceAtop, + Blend.XOR, + Blend.MaskInvert, + ]; + + public static Blend Resolve(double value) + { + if (double.IsNaN(value)) + return Blend.Normal; + + int index = (int)value; + return (uint)index < (uint)Order.Length ? Order[index] : Blend.Normal; + } + } +}