예제 #1
0
        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));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
 public static FinColor Random()
 {
     var(r, g, b) = FinRandom.Bytes3();
     return(FinColor.FromRgbB(r, g, b));
 }
예제 #5
0
 public static FinColor FromCColor(Color color)
 => FinColor.FromRgbaB(color.R, color.G, color.B, color.A);
예제 #6
0
 public static FinColor FromVB(byte v) => FinColor.FromRgbB(v, v, v);
예제 #7
0
 public static FinColor FromRgbF(float r, float g, float b)
 => FinColor.FromRgbaF(r, g, b, 1);
예제 #8
0
 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));
예제 #9
0
 public static FinColor FromRgbB(byte r, byte g, byte b)
 => FinColor.FromRgbaB(r, g, b, 255);