示例#1
0
        public void ColorBGRAHF_Accessor()
        {
            HalfFloat r = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat g = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat b = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat a = (HalfFloat)NextComponent((HalfFloat)1.0f);

            ColorBGRAHF v = new ColorBGRAHF(r, g, b, a);
            float       c;

            Assert.DoesNotThrow(() => c = v[0]);
            Assert.DoesNotThrow(() => c = v[1]);
            Assert.DoesNotThrow(() => c = v[2]);
            Assert.DoesNotThrow(() => c = v[3]);
            Assert.Throws <IndexOutOfRangeException>(() => c = v[+4]);
            Assert.Throws <IndexOutOfRangeException>(() => c = v[-1]);

            Assert.DoesNotThrow(() => v[0] = 1.0f);
            Assert.DoesNotThrow(() => v[1] = 1.0f);
            Assert.DoesNotThrow(() => v[2] = 1.0f);
            Assert.DoesNotThrow(() => v[3] = 1.0f);
            Assert.Throws <IndexOutOfRangeException>(() => v[+4] = 0.0f);
            Assert.Throws <IndexOutOfRangeException>(() => v[-1] = 0.0f);

            Assert.DoesNotThrow(() => v[3] = 0.0f);
            Assert.DoesNotThrow(() => v[3] = 1.0f);
            Assert.Throws <InvalidOperationException>(() => v[3] = -1.0f);
            Assert.Throws <InvalidOperationException>(() => v[3] = +1.1f);
        }
示例#2
0
        public void ColorBGRAHF_PixelType()
        {
            HalfFloat r = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat g = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat b = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat a = (HalfFloat)NextComponent((HalfFloat)1.0f);

            ColorBGRAHF v = new ColorBGRAHF(r, g, b, a);

            Assert.AreNotEqual(PixelLayout.None, v.PixelType);
        }
示例#3
0
        public void ColorBGRAHF_TestConstructor1()
        {
            HalfFloat r = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat g = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat b = (HalfFloat)NextComponent((HalfFloat)1.0f);

            ColorBGRAHF v = new ColorBGRAHF(r, g, b);

            Assert.AreEqual(r, v.r);
            Assert.AreEqual(g, v.g);
            Assert.AreEqual(b, v.b);
            Assert.AreEqual((HalfFloat)1.0f, v.a);
        }
示例#4
0
        public void ColorBGRHF_CastToBGRA()
        {
            HalfFloat r = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat g = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat b = (HalfFloat)NextComponent((HalfFloat)1.0f);

            ColorBGRHF  v     = new ColorBGRHF(r, g, b);
            ColorBGRAHF vBGRA = v;

            Assert.AreEqual(v.Red, vBGRA.Red);
            Assert.AreEqual(v.Green, vBGRA.Green);
            Assert.AreEqual(v.Blue, vBGRA.Blue);
            Assert.AreEqual((HalfFloat)1.0f, vBGRA.Alpha);
        }
示例#5
0
        public void ColorBGRAHF_CastToVertex4()
        {
            HalfFloat r = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat g = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat b = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat a = (HalfFloat)NextComponent((HalfFloat)1.0f);

            ColorBGRAHF v      = new ColorBGRAHF(r, g, b, a);
            Vertex4hf   vArray = v;

            Assert.AreEqual(r, vArray.x);
            Assert.AreEqual(g, vArray.y);
            Assert.AreEqual(b, vArray.z);
            Assert.AreEqual(a, vArray.w);
        }
示例#6
0
        public void ColorBGRAHF_TestConstructor2()
        {
            Random    random = new Random();
            HalfFloat r      = (HalfFloat)NextComponent(random, (HalfFloat)1.0f);
            HalfFloat g      = (HalfFloat)NextComponent(random, (HalfFloat)1.0f);
            HalfFloat b      = (HalfFloat)NextComponent(random, (HalfFloat)1.0f);
            HalfFloat a      = (HalfFloat)NextComponent(random, (HalfFloat)1.0f);

            ColorBGRAHF v = new ColorBGRAHF(r, g, b, a);

            Assert.AreEqual(r, v.r);
            Assert.AreEqual(g, v.g);
            Assert.AreEqual(b, v.b);
            Assert.AreEqual(a, v.a);
        }
示例#7
0
        public void ColorBGRAHF_Multiply()
        {
            HalfFloat r = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat g = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat b = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat a = (HalfFloat)NextComponent((HalfFloat)1.0f);

            ColorBGRAHF v = new ColorBGRAHF(r, g, b, a);
            ColorBGRAHF c = v * 0.5f;

            c = c * 2.0f;

            Assert.AreEqual(c.r, v.r, 1.0);
            Assert.AreEqual(c.g, v.g, 1.0);
            Assert.AreEqual(c.b, v.b, 1.0);
            Assert.AreEqual(c.a, v.a, 1.0);
        }
示例#8
0
        public void ColorBGRAHF_CastToArray()
        {
            HalfFloat r = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat g = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat b = (HalfFloat)NextComponent((HalfFloat)1.0f);
            HalfFloat a = (HalfFloat)NextComponent((HalfFloat)1.0f);

            ColorBGRAHF v = new ColorBGRAHF(r, g, b, a);

            HalfFloat[] vArray = v;

            Assert.AreEqual(4, vArray.Length);
            Assert.AreEqual(r, vArray[0]);
            Assert.AreEqual(g, vArray[1]);
            Assert.AreEqual(b, vArray[2]);
            Assert.AreEqual(a, vArray[3]);
        }
示例#9
0
        public void ColorBGRAHF_CastFromColor()
        {
            const double Epsilon = 1e-2;

            double r = NextComponent(1.0);
            double g = NextComponent(1.0);
            double b = NextComponent(1.0);
            double a = NextComponent(1.0);

            Color c = Color.FromArgb((int)(a * byte.MaxValue), (int)(r * byte.MaxValue), (int)(g * byte.MaxValue), (int)(b * byte.MaxValue));

            ColorBGRAHF v = (ColorBGRAHF)c;

            Assert.AreEqual((float)r, v[0], Epsilon);
            Assert.AreEqual((float)g, v[1], Epsilon);
            Assert.AreEqual((float)b, v[2], Epsilon);
            Assert.AreEqual((float)a, v[3], Epsilon);
        }