public SerializableColorF(float r, float g, float b, float a) { this.R = FlaiMath.Clamp((byte)(r * 255), byte.MinValue, byte.MaxValue); this.G = FlaiMath.Clamp((byte)(g * 255), byte.MinValue, byte.MaxValue); this.B = FlaiMath.Clamp((byte)(b * 255), byte.MinValue, byte.MaxValue); this.A = FlaiMath.Clamp((byte)(a * 255), byte.MinValue, byte.MaxValue); }
public ColorF(float r, float g, float b) { this.R = FlaiMath.Clamp((byte)(r * 255), byte.MinValue, byte.MaxValue); this.G = FlaiMath.Clamp((byte)(g * 255), byte.MinValue, byte.MaxValue); this.B = FlaiMath.Clamp((byte)(b * 255), byte.MinValue, byte.MaxValue); this.A = 255; }
public static Vector2f ClampY(Vector2f vec, float min, float max) { Ensure.True(min <= max); vec.Y = FlaiMath.Clamp(vec.Y, min, max); return(vec); }
public static Vector2f Clamp(Vector2f value, Vector2f min, Vector2f max) { return(new Vector2f(FlaiMath.Clamp(value.X, min.X, max.X), FlaiMath.Clamp(value.Y, min.Y, max.Y))); }
public static double SmoothStep(double value1, double value2, double amount) { double num = FlaiMath.Clamp(amount, 0f, 1f); return(FlaiMath.Lerp(value1, value2, num * num * (3f - 2f * num))); }
public static float SmoothStep(float value1, float value2, float amount) { float num = FlaiMath.Clamp(amount, 0f, 1f); return(FlaiMath.Lerp(value1, value2, num * num * (3f - 2f * num))); }
public static ColorF operator *(ColorF color, float multiplier) { return(new ColorF(color.R, color.G, color.B, (byte)FlaiMath.Clamp(color.A * multiplier, 0, 255))); }
// smoothstep public static ColorF Slerp(Color from, Color to, float amount) { amount = FlaiMath.Clamp(amount, 0, 1); return(ColorF.Lerp(from, to, amount * amount * (3f - 2f * amount))); }
public static ColorF Lerp(ColorF from, ColorF to, float amount) { // from UnityEngine.Color32 amount = FlaiMath.Clamp(amount, 0, 1); return(new Color32((byte)(from.R + (to.R - from.R) * amount), (byte)(from.G + (to.G - from.G) * amount), (byte)(from.B + (to.B - from.B) * amount), (byte)(from.A + (to.A - from.A) * amount))); }
public static Vector2d ClampY(Vector2d vec, double min, double max) { Ensure.True(min <= max); vec.Y = FlaiMath.Clamp(vec.Y, min, max); return(vec); }