public void ColorBGR48_CastFromColor() { const double Epsilon = 0.25; Random random = new Random(); double r = NextComponent(random, 1.0); double g = NextComponent(random, 1.0); double b = NextComponent(random, 1.0); Color c = Color.FromArgb(byte.MaxValue, (int)(r * byte.MaxValue), (int)(g * byte.MaxValue), (int)(b * byte.MaxValue)); ColorBGR48 v = (ColorBGR48)c; Assert.AreEqual((float)r, v[0], Epsilon); Assert.AreEqual((float)g, v[1], Epsilon); Assert.AreEqual((float)b, v[2], Epsilon); // Not influenced by alpha c = Color.FromArgb(0, (int)(r * byte.MaxValue), (int)(g * byte.MaxValue), (int)(b * byte.MaxValue)); v = (ColorBGR48)c; Assert.AreEqual((float)r, v[0], Epsilon); Assert.AreEqual((float)g, v[1], Epsilon); Assert.AreEqual((float)b, v[2], Epsilon); }
public void ColorBGR48_Accessor() { ushort r = (ushort)NextComponent(ushort.MaxValue); ushort g = (ushort)NextComponent(ushort.MaxValue); ushort b = (ushort)NextComponent(ushort.MaxValue); ColorBGR48 v = new ColorBGR48(r, g, b); float c; Assert.DoesNotThrow(() => c = v[0]); Assert.DoesNotThrow(() => c = v[1]); Assert.DoesNotThrow(() => c = v[2]); Assert.Throws <IndexOutOfRangeException>(() => c = v[+3]); 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.Throws <IndexOutOfRangeException>(() => v[+3] = 0.0f); Assert.Throws <IndexOutOfRangeException>(() => v[-1] = 0.0f); Assert.DoesNotThrow(() => v[2] = 0.0f); Assert.DoesNotThrow(() => v[2] = 1.0f); Assert.Throws <InvalidOperationException>(() => v[2] = -1.0f); Assert.Throws <InvalidOperationException>(() => v[2] = +1.1f); }
public void ColorBGR48_PixelType() { ushort r = (ushort)NextComponent(ushort.MaxValue); ushort g = (ushort)NextComponent(ushort.MaxValue); ushort b = (ushort)NextComponent(ushort.MaxValue); ColorBGR48 v = new ColorBGR48(r, g, b); Assert.AreNotEqual(PixelLayout.None, v.PixelType); }
public void ColorBGR48_TestConstructor1() { ushort r = (ushort)ushort.MaxValue; ushort g = (ushort)ushort.MaxValue; ushort b = (ushort)ushort.MaxValue; ColorBGR48 v = new ColorBGR48(r, g, b); Assert.AreEqual(r, v.Red); Assert.AreEqual(g, v.Green); Assert.AreEqual(b, v.Blue); }
public void ColorBGR48_CastToVertex4() { ushort r = (ushort)NextComponent(ushort.MaxValue); ushort g = (ushort)NextComponent(ushort.MaxValue); ushort b = (ushort)NextComponent(ushort.MaxValue); ColorBGR48 v = new ColorBGR48(r, g, b); Vertex3us vArray = v; Assert.AreEqual(b, vArray.x); Assert.AreEqual(g, vArray.y); Assert.AreEqual(r, vArray.z); }
public void ColorBGR48_CastToBGRA() { ushort r = (ushort)NextComponent(ushort.MaxValue); ushort g = (ushort)NextComponent(ushort.MaxValue); ushort b = (ushort)NextComponent(ushort.MaxValue); ColorBGR48 v = new ColorBGR48(r, g, b); ColorBGRA64 vBGRA = v; Assert.AreEqual(v.Red, vBGRA.Red); Assert.AreEqual(v.Green, vBGRA.Green); Assert.AreEqual(v.Blue, vBGRA.Blue); Assert.AreEqual(ushort.MaxValue, vBGRA.Alpha); }
public void ColorBGR48_CastToArray() { ushort r = (ushort)NextComponent(ushort.MaxValue); ushort g = (ushort)NextComponent(ushort.MaxValue); ushort b = (ushort)NextComponent(ushort.MaxValue); ColorBGR48 v = new ColorBGR48(r, g, b); ushort[] vArray = v; Assert.AreEqual(3, vArray.Length); Assert.AreEqual(b, vArray[0]); Assert.AreEqual(g, vArray[1]); Assert.AreEqual(r, vArray[2]); }