public void NormalizedShort4() { // Test PackedValue Assert.Equal((ulong)0x0, new NormalizedShort4(Vector4.Zero).PackedValue); Assert.Equal((ulong)0x7FFF7FFF7FFF7FFF, new NormalizedShort4(Vector4.One).PackedValue); Assert.Equal(0x8001800180018001, new NormalizedShort4(-Vector4.One).PackedValue); // Test ToVector4 Assert.True(Equal(Vector4.One, new NormalizedShort4(Vector4.One).ToVector4())); Assert.True(Equal(Vector4.Zero, new NormalizedShort4(Vector4.Zero).ToVector4())); Assert.True(Equal(-Vector4.One, new NormalizedShort4(-Vector4.One).ToVector4())); Assert.True(Equal(Vector4.One, new NormalizedShort4(Vector4.One * 1234.0f).ToVector4())); Assert.True(Equal(-Vector4.One, new NormalizedShort4(Vector4.One * -1234.0f).ToVector4())); // Test ToScaledVector4. Vector4 scaled = new NormalizedShort4(Vector4.One).ToScaledVector4(); Assert.Equal(1, scaled.X); Assert.Equal(1, scaled.Y); Assert.Equal(1, scaled.Z); Assert.Equal(1, scaled.W); // Test PackFromScaledVector4. var pixel = default(NormalizedShort4); pixel.PackFromScaledVector4(scaled); Assert.Equal((ulong)0x7FFF7FFF7FFF7FFF, pixel.PackedValue); // Test Ordering float x = 0.1f; float y = -0.3f; float z = 0.5f; float w = -0.7f; Assert.Equal(0xa6674000d99a0ccd, new NormalizedShort4(x, y, z, w).PackedValue); Assert.Equal((ulong)4150390751449251866, new NormalizedShort4(0.0008f, 0.15f, 0.30f, 0.45f).PackedValue); var rgb = default(Rgb24); var rgba = default(Rgba32); var bgr = default(Bgr24); var bgra = default(Bgra32); new NormalizedShort4(x, y, z, w).ToRgb24(ref rgb); Assert.Equal(rgb, new Rgb24(141, 90, 192)); new NormalizedShort4(x, y, z, w).ToRgba32(ref rgba); Assert.Equal(rgba, new Rgba32(141, 90, 192, 39)); new NormalizedShort4(x, y, z, w).ToBgr24(ref bgr); Assert.Equal(bgr, new Bgr24(141, 90, 192)); new NormalizedShort4(x, y, z, w).ToBgra32(ref bgra); Assert.Equal(bgra, new Bgra32(141, 90, 192, 39)); var r = new NormalizedShort4(); r.PackFromRgba32(new Rgba32(9, 115, 202, 127)); r.ToRgba32(ref rgba); Assert.Equal(rgba, new Rgba32(9, 115, 202, 127)); }
public void NormalizedShort4_ToRgba32() { // arrange var byte4 = new NormalizedShort4(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); var expected = new Rgba32(Vector4.One); var actual = default(Rgba32); // act byte4.ToRgba32(ref actual); Assert.Equal(expected, actual); }
public void NormalizedShort4_ToRgba32() { // arrange var short4 = new NormalizedShort4(0.1f, -0.3f, 0.5f, -0.7f); var actual = default(Rgba32); var expected = new Rgba32(141, 90, 192, 39); // act short4.ToRgba32(ref actual); // assert Assert.Equal(expected, actual); }