public void ColorRGBA32_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); ColorRGBA32 v = new ColorRGBA32(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 ColorRGBA32_OperatorInequality() { ColorRGBA32 v = ColorRGBA32.ColorRed; Assert.IsFalse(v != ColorRGBA32.ColorRed); Assert.IsTrue(v != ColorRGBA32.ColorGreen); }
public void ColorRGBA32_Equals_ColorRGBA32() { ColorRGBA32 v = ColorRGBA32.ColorRed; Assert.IsTrue(v.Equals(ColorRGBA32.ColorRed)); Assert.IsFalse(v.Equals(ColorRGBA32.ColorGreen)); Assert.IsFalse(v.Equals(ColorRGBA32.ColorBlue)); }
public void ColorRGB24_CastToRGBA() { byte r = (byte)NextComponent(byte.MaxValue); byte g = (byte)NextComponent(byte.MaxValue); byte b = (byte)NextComponent(byte.MaxValue); ColorRGB24 v = new ColorRGB24(r, g, b); ColorRGBA32 vRGBA = v; }
public void AddColor(ushort time, float r, float g, float b) { switch (NumColorKeys) { case 0: Key0 = new ColorRGBAf(r, g, b, Key0.A); Key32_0 = new ColorRGBA32(Key0); Ctime0 = time; break; case 1: Key1 = new ColorRGBAf(r, g, b, Key1.A); Key32_1 = new ColorRGBA32(Key1); Ctime1 = time; break; case 2: Key2 = new ColorRGBAf(r, g, b, Key2.A); Key32_2 = new ColorRGBA32(Key2); Ctime2 = time; break; case 3: Key3 = new ColorRGBAf(r, g, b, Key3.A); Key32_3 = new ColorRGBA32(Key3); Ctime3 = time; break; case 4: Key4 = new ColorRGBAf(r, g, b, Key4.A); Key32_4 = new ColorRGBA32(Key4); Ctime4 = time; break; case 5: Key5 = new ColorRGBAf(r, g, b, Key5.A); Key32_5 = new ColorRGBA32(Key5); Ctime5 = time; break; case 6: Key6 = new ColorRGBAf(r, g, b, Key6.A); Key32_6 = new ColorRGBA32(Key6); Ctime6 = time; break; case 7: Key7 = new ColorRGBAf(r, g, b, Key7.A); Key32_7 = new ColorRGBA32(Key7); Ctime7 = time; break; default: throw new NotSupportedException(); } NumColorKeys++; }
public void AddAlpha(ushort time, float a) { switch (NumAlphaKeys) { case 0: Key0 = new ColorRGBAf(Key0.R, Key0.G, Key0.B, a); Key32_0 = new ColorRGBA32(Key0); Atime0 = time; break; case 1: Key1 = new ColorRGBAf(Key0.R, Key0.G, Key0.B, a); Key32_1 = new ColorRGBA32(Key1); Atime1 = time; break; case 2: Key2 = new ColorRGBAf(Key0.R, Key0.G, Key0.B, a); Key32_2 = new ColorRGBA32(Key2); Atime2 = time; break; case 3: Key3 = new ColorRGBAf(Key0.R, Key0.G, Key0.B, a); Key32_3 = new ColorRGBA32(Key3); Atime3 = time; break; case 4: Key4 = new ColorRGBAf(Key0.R, Key0.G, Key0.B, a); Key32_4 = new ColorRGBA32(Key4); Atime4 = time; break; case 5: Key5 = new ColorRGBAf(Key0.R, Key0.G, Key0.B, a); Key32_5 = new ColorRGBA32(Key5); Atime5 = time; break; case 6: Key6 = new ColorRGBAf(Key0.R, Key0.G, Key0.B, a); Key32_6 = new ColorRGBA32(Key6); Atime6 = time; break; case 7: Key7 = new ColorRGBAf(Key0.R, Key0.G, Key0.B, a); Key32_7 = new ColorRGBA32(Key7); Atime7 = time; break; default: throw new NotSupportedException(); } NumAlphaKeys++; }
public void ColorRGBA32_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); ColorRGBA32 v = new ColorRGBA32(r, g, b, a); Assert.AreNotEqual(PixelLayout.None, v.PixelType); }
public void ColorRGBA32_GetHashCode() { byte r = (byte)NextComponent(byte.MaxValue); byte g = (byte)NextComponent(byte.MaxValue); byte b = (byte)NextComponent(byte.MaxValue); byte a = (byte)NextComponent(byte.MaxValue); ColorRGBA32 v = new ColorRGBA32(r, g, b, a); Assert.DoesNotThrow(() => v.GetHashCode()); }
public void ColorRGBA32_Equals_Object() { ColorRGBA32 v = ColorRGBA32.ColorRed; Assert.IsFalse(v.Equals(null)); Assert.IsFalse(v.Equals(String.Empty)); Assert.IsFalse(v.Equals(0.0f)); Assert.IsTrue(v.Equals((object)ColorRGBA32.ColorRed)); Assert.IsFalse(v.Equals((object)ColorRGBA32.ColorGreen)); Assert.IsFalse(v.Equals((object)ColorRGBA32.ColorBlue)); }
public void ColorRGBA32_TestConstructor1() { byte r = (byte)NextComponent(byte.MaxValue); byte g = (byte)NextComponent(byte.MaxValue); byte b = (byte)NextComponent(byte.MaxValue); ColorRGBA32 v = new ColorRGBA32(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 ColorRGB24_CastToRGBA() { byte r = (byte)NextComponent(byte.MaxValue); byte g = (byte)NextComponent(byte.MaxValue); byte b = (byte)NextComponent(byte.MaxValue); ColorRGB24 v = new ColorRGB24(r, g, b); ColorRGBA32 vRGBA = v; Assert.AreEqual(v.Red, vRGBA.Red); Assert.AreEqual(v.Green, vRGBA.Green); Assert.AreEqual(v.Blue, vRGBA.Blue); Assert.AreEqual(byte.MaxValue, vRGBA.Alpha); }
public void ColorRGBA32_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); ColorRGBA32 v = new ColorRGBA32(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 ColorRGBA32_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); ColorRGBA32 v = new ColorRGBA32(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 ColorRGBA32_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); ColorRGBA32 v = new ColorRGBA32(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 ColorRGBA32_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); ColorRGBA32 v = new ColorRGBA32(r, g, b, a); ColorRGBA32 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 ColorRGBA32_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)); ColorRGBA32 v = (ColorRGBA32)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); }
public MinMaxGradient(bool _) { MinMaxState = MinMaxGradientState.Color; MinColor = new ColorRGBAf(1.0f, 1.0f, 1.0f, 1.0f); MinColor32 = new ColorRGBA32(255, 255, 255, 255); MaxColor = new ColorRGBAf(1.0f, 1.0f, 1.0f, 1.0f); MaxColor32 = new ColorRGBA32(255, 255, 255, 255); MaxGradient = default; MaxGradient.AddColor(0, 1.0f, 1.0f, 1.0f); MaxGradient.AddColor(ushort.MaxValue, 1.0f, 1.0f, 1.0f); MaxGradient.AddAlpha(0, 1.0f); MaxGradient.AddAlpha(ushort.MaxValue, 1.0f); MinGradient = default; MinGradient.AddColor(0, 1.0f, 1.0f, 1.0f); MinGradient.AddColor(ushort.MaxValue, 1.0f, 1.0f, 1.0f); MinGradient.AddAlpha(0, 1.0f); MinGradient.AddAlpha(ushort.MaxValue, 1.0f); }
public void Add(ushort time, ColorRGBA32 color) { Add(time, (ColorRGBAf)color); }
private static void GenerateEngineStruct(TypeTreeContext context, SerializableType origin, string name) { switch (origin.Name) { case SerializableType.Vector2Name: Vector2f.GenerateTypeTree(context, name); break; case SerializableType.Vector2IntName: Vector2i.GenerateTypeTree(context, name); break; case SerializableType.Vector3Name: Vector3f.GenerateTypeTree(context, name); break; case SerializableType.Vector3IntName: Vector3i.GenerateTypeTree(context, name); break; case SerializableType.Vector4Name: Vector4f.GenerateTypeTree(context, name); break; case SerializableType.RectName: Rectf.GenerateTypeTree(context, name); break; case SerializableType.BoundsName: AABB.GenerateTypeTree(context, name); break; case SerializableType.BoundsIntName: AABBi.GenerateTypeTree(context, name); break; case SerializableType.QuaternionName: Quaternionf.GenerateTypeTree(context, name); break; case SerializableType.Matrix4x4Name: Matrix4x4f.GenerateTypeTree(context, name); break; case SerializableType.ColorName: ColorRGBAf.GenerateTypeTree(context, name); break; case SerializableType.Color32Name: ColorRGBA32.GenerateTypeTree(context, name); break; case SerializableType.LayerMaskName: LayerMask.GenerateTypeTree(context, name); break; case SerializableType.AnimationCurveName: AnimationCurveTpl <Float> .GenerateTypeTree(context, name, Float.GenerateTypeTree); break; case SerializableType.GradientName: Gradient.GenerateTypeTree(context, name); break; case SerializableType.RectOffsetName: RectOffset.GenerateTypeTree(context, name); break; case SerializableType.GUIStyleName: GUIStyle.GenerateTypeTree(context, name); break; case SerializableType.PropertyNameName: PropertyName.GenerateTypeTree(context, name); break; default: throw new Exception($"Unknown engine struct {origin.Name}"); } }