public static FinColor FromRgbaB(byte r, byte g, byte b, byte a) { var rr = (uint)((r & 0xff) << 24); var gg = (uint)((g & 0xff) << 16); var bb = (uint)((b & 0xff) << 8); var aa = (uint)(a & 0xff); return(FinColor.FromRgba(rr + gg + bb + aa)); }
public void TestFromRgbaB() { var color = FinColor.FromRgbaB(1, 2, 3, 4); Assert.AreEqual(1, color.Rb); Assert.AreEqual(2, color.Gb); Assert.AreEqual(3, color.Bb); Assert.AreEqual(4, color.Ab); }
public void TestFromRgbaF() { var color = FinColor.FromRgbaF(.1f, .2f, .3f, .4f); var tolerance = .01f; Assert.AreEqual(.1, color.Rf, tolerance); Assert.AreEqual(.2, color.Gf, tolerance); Assert.AreEqual(.3, color.Bf, tolerance); Assert.AreEqual(.4, color.Af, tolerance); }
public static FinColor Random() { var(r, g, b) = FinRandom.Bytes3(); return(FinColor.FromRgbB(r, g, b)); }
public static FinColor FromCColor(Color color) => FinColor.FromRgbaB(color.R, color.G, color.B, color.A);
public static FinColor FromVB(byte v) => FinColor.FromRgbB(v, v, v);
public static FinColor FromRgbF(float r, float g, float b) => FinColor.FromRgbaF(r, g, b, 1);
public static FinColor FromRgbaF(float r, float g, float b, float a) => FinColor.FromRgbaB((byte)(r * 255), (byte)(g * 255), (byte)(b * 255), (byte)(a * 255));
public static FinColor FromRgbB(byte r, byte g, byte b) => FinColor.FromRgbaB(r, g, b, 255);