Beispiel #1
0
        public void ColorBGRAF_Accessor()
        {
            float r = (float)NextComponent(1.0f);
            float g = (float)NextComponent(1.0f);
            float b = (float)NextComponent(1.0f);
            float a = (float)NextComponent(1.0f);

            ColorBGRAF v = new ColorBGRAF(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);
        }
Beispiel #2
0
        public void ColorBGRAF_PixelType()
        {
            float r = (float)NextComponent(1.0f);
            float g = (float)NextComponent(1.0f);
            float b = (float)NextComponent(1.0f);
            float a = (float)NextComponent(1.0f);

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

            Assert.AreNotEqual(PixelLayout.None, v.PixelType);
        }
Beispiel #3
0
        public void ColorBGRAF_TestConstructor1()
        {
            float r = (float)NextComponent(1.0f);
            float g = (float)NextComponent(1.0f);
            float b = (float)NextComponent(1.0f);

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

            Assert.AreEqual(r, v.r);
            Assert.AreEqual(g, v.g);
            Assert.AreEqual(b, v.b);
            Assert.AreEqual(1.0f, v.a);
        }
Beispiel #4
0
        public void ColorBGRF_CastToBGRA()
        {
            float r = (float)NextComponent(1.0f);
            float g = (float)NextComponent(1.0f);
            float b = (float)NextComponent(1.0f);

            ColorBGRF  v     = new ColorBGRF(r, g, b);
            ColorBGRAF vBGRA = v;

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

            ColorBGRAF v      = new ColorBGRAF(r, g, b, a);
            Vertex4f   vArray = v;

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

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

            Assert.AreEqual(r, v.r);
            Assert.AreEqual(g, v.g);
            Assert.AreEqual(b, v.b);
            Assert.AreEqual(a, v.a);
        }
Beispiel #7
0
        public void ColorBGRAF_Multiply()
        {
            float r = (float)NextComponent(1.0f);
            float g = (float)NextComponent(1.0f);
            float b = (float)NextComponent(1.0f);
            float a = (float)NextComponent(1.0f);

            ColorBGRAF v = new ColorBGRAF(r, g, b, a);
            ColorBGRAF 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);
        }
Beispiel #8
0
        public void ColorBGRAF_CastToArray()
        {
            float r = (float)NextComponent(1.0f);
            float g = (float)NextComponent(1.0f);
            float b = (float)NextComponent(1.0f);
            float a = (float)NextComponent(1.0f);

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

            float[] 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]);
        }
Beispiel #9
0
        public void ColorBGRAF_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));

            ColorBGRAF v = (ColorBGRAF)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);
        }