public static Color Add(Color c0, Color c1, bool sRGBSpace) { if (sRGBSpace) { return(new Color(c0.R + c1.R, c0.G + c1.G, c0.B + c1.B, c0.A + c1.A)); } else { float lr0, lg0, lb0, la0; c0.ToLinearRGB(out lr0, out lg0, out lb0, out la0); float lr1, lg1, lb1, la1; c1.ToLinearRGB(out lr1, out lg1, out lb1, out la1); return(Color.FromLinearRGB(lr0 + lr1, lg0 + lg1, lb0 + lb1, la0 + la1)); } }
public static Color Lerp(Color c0, Color c1, float t, bool sRGBSpace) { if (sRGBSpace) { return(new Color( Lerp(c0.R, c1.R, t), Lerp(c0.G, c1.G, t), Lerp(c0.B, c1.B, t), Lerp(c0.A, c1.A, t))); } else { float lr0, lg0, lb0, la0; c0.ToLinearRGB(out lr0, out lg0, out lb0, out la0); float lr1, lg1, lb1, la1; c1.ToLinearRGB(out lr1, out lg1, out lb1, out la1); return(Color.FromLinearRGB( Lerp(lr0, lr1, t), Lerp(lg0, lg1, t), Lerp(lb0, lb1, t), Lerp(la0, la1, t))); } }