public void ColorBGRA32_Accessor() { byte r = (byte)NextComponent(byte.MaxValue); byte g = (byte)NextComponent(byte.MaxValue); byte b = (byte)NextComponent(byte.MaxValue); byte a = (byte)NextComponent(byte.MaxValue); ColorBGRA32 v = new ColorBGRA32(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); }
public void ColorBGRA32_PixelType() { byte r = (byte)NextComponent(byte.MaxValue); byte g = (byte)NextComponent(byte.MaxValue); byte b = (byte)NextComponent(byte.MaxValue); byte a = (byte)NextComponent(byte.MaxValue); ColorBGRA32 v = new ColorBGRA32(r, g, b, a); Assert.AreNotEqual(PixelLayout.None, v.PixelType); }
public void ColorBGRA32_TestConstructor1() { byte r = (byte)NextComponent(byte.MaxValue); byte g = (byte)NextComponent(byte.MaxValue); byte b = (byte)NextComponent(byte.MaxValue); ColorBGRA32 v = new ColorBGRA32(r, g, b); Assert.AreEqual(r, v.r); Assert.AreEqual(g, v.g); Assert.AreEqual(b, v.b); Assert.AreEqual(byte.MaxValue, v.a); }
public void ColorBGR24_CastToBGRA() { byte r = (byte)NextComponent(byte.MaxValue); byte g = (byte)NextComponent(byte.MaxValue); byte b = (byte)NextComponent(byte.MaxValue); ColorBGR24 v = new ColorBGR24(r, g, b); ColorBGRA32 vBGRA = v; Assert.AreEqual(v.Red, vBGRA.Red); Assert.AreEqual(v.Green, vBGRA.Green); Assert.AreEqual(v.Blue, vBGRA.Blue); Assert.AreEqual(byte.MaxValue, vBGRA.Alpha); }
public void ColorBGRA32_CastToVertex4() { byte r = (byte)NextComponent(byte.MaxValue); byte g = (byte)NextComponent(byte.MaxValue); byte b = (byte)NextComponent(byte.MaxValue); byte a = (byte)NextComponent(byte.MaxValue); ColorBGRA32 v = new ColorBGRA32(r, g, b, a); Vertex4ub vArray = v; Assert.AreEqual(r, vArray.x); Assert.AreEqual(g, vArray.y); Assert.AreEqual(b, vArray.z); Assert.AreEqual(a, vArray.w); }
public void ColorBGRA32_TestConstructor2() { Random random = new Random(); byte r = (byte)NextComponent(random, byte.MaxValue); byte g = (byte)NextComponent(random, byte.MaxValue); byte b = (byte)NextComponent(random, byte.MaxValue); byte a = (byte)NextComponent(random, byte.MaxValue); ColorBGRA32 v = new ColorBGRA32(r, g, b, a); Assert.AreEqual(r, v.r); Assert.AreEqual(g, v.g); Assert.AreEqual(b, v.b); Assert.AreEqual(a, v.a); }
public void ColorBGRA32_CastToArray() { byte r = (byte)NextComponent(byte.MaxValue); byte g = (byte)NextComponent(byte.MaxValue); byte b = (byte)NextComponent(byte.MaxValue); byte a = (byte)NextComponent(byte.MaxValue); ColorBGRA32 v = new ColorBGRA32(r, g, b, a); byte[] 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]); }
public void ColorBGRA32_Multiply() { byte r = (byte)NextComponent(byte.MaxValue); byte g = (byte)NextComponent(byte.MaxValue); byte b = (byte)NextComponent(byte.MaxValue); byte a = (byte)NextComponent(byte.MaxValue); ColorBGRA32 v = new ColorBGRA32(r, g, b, a); ColorBGRA32 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); }
public void ColorBGRA32_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)); ColorBGRA32 v = (ColorBGRA32)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); }