public Color4f(IColor4 other) { ITuple4_Float _other = other.AsTupleFloat(); this.Red = _other.X; this.Green = _other.Y; this.Blue = _other.Z; this.Alpha = _other.W; }
public static ITuple4_Float AsTupleFloat(this IColor4 v) { ITuple4_Float ret = v as ITuple4_Float; if (ret != null) { return(ret); } return(VectorUtils.Convert <IColor4, ITuple4_Float>(v)); }
public void TestConvert_Double() { // 2D - vectors { ITuple2_Float v = VectorUtils.Convert <ITuple2_Float>(new Vector2d(1, 2)); Assert.IsTrue(v.X == 1 && v.Y == 2); } { ITuple2_Integer v = VectorUtils.Convert <ITuple2_Integer>(new Vector2d(1, 2)); Assert.IsTrue(v.X == 1 && v.Y == 2); } { ITuple2_Byte v = VectorUtils.Convert <ITuple2_Byte>(new Vector2d(1, 2)); Assert.IsTrue(v.X == 1 && v.Y == 2); } { ITuple2_Float v = VectorUtils.Convert <ITuple2_Float>(new BuffVector2d(1, 2)); Assert.IsTrue(v.X == 1 && v.Y == 2); } { ITuple2_Integer v = VectorUtils.Convert <ITuple2_Integer>(new BuffVector2d(1, 2)); Assert.IsTrue(v.X == 1 && v.Y == 2); } { ITuple2_Byte v = VectorUtils.Convert <ITuple2_Byte>(new BuffVector2d(1, 2)); Assert.IsTrue(v.X == 1 && v.Y == 2); } // 2D - points { ITuple2_Float v = VectorUtils.Convert <ITuple2_Float>(new Point2d(1, 2)); Assert.IsTrue(v.X == 1 && v.Y == 2); } { ITuple2_Integer v = VectorUtils.Convert <ITuple2_Integer>(new Point2d(1, 2)); Assert.IsTrue(v.X == 1 && v.Y == 2); } { ITuple2_Byte v = VectorUtils.Convert <ITuple2_Byte>(new Point2d(1, 2)); Assert.IsTrue(v.X == 1 && v.Y == 2); } { ITuple2_Float v = VectorUtils.Convert <ITuple2_Float>(new BuffPoint2d(1, 2)); Assert.IsTrue(v.X == 1 && v.Y == 2); } { ITuple2_Integer v = VectorUtils.Convert <ITuple2_Integer>(new BuffPoint2d(1, 2)); Assert.IsTrue(v.X == 1 && v.Y == 2); } { ITuple2_Byte v = VectorUtils.Convert <ITuple2_Byte>(new BuffPoint2d(1, 2)); Assert.IsTrue(v.X == 1 && v.Y == 2); } // 3D - vectors { ITuple3_Float v = VectorUtils.Convert <ITuple3_Float>(new Vector3d(1, 2, 3)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3); } { ITuple3_Byte v = VectorUtils.Convert <ITuple3_Byte>(new Vector3d(1, 2, 3)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3); } { ITuple3_Float v = VectorUtils.Convert <ITuple3_Float>(new BuffVector3d(1, 2, 3)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3); } { ITuple3_Byte v = VectorUtils.Convert <ITuple3_Byte>(new BuffVector3d(1, 2, 3)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3); } // 3D - points { ITuple3_Float v = VectorUtils.Convert <ITuple3_Float>(new Point3d(1, 2, 3)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3); } { ITuple3_Byte v = VectorUtils.Convert <ITuple3_Byte>(new Point3d(1, 2, 3)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3); } { ITuple3_Float v = VectorUtils.Convert <ITuple3_Float>(new BuffPoint3d(1, 2, 3)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3); } { ITuple3_Byte v = VectorUtils.Convert <ITuple3_Byte>(new BuffPoint3d(1, 2, 3)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3); } // 4D - vectors { ITuple4_Float v = VectorUtils.Convert <ITuple4_Float>(new Vector4d(1, 2, 3, 4)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4); } { ITuple4_Byte v = VectorUtils.Convert <ITuple4_Byte>(new Vector4d(1, 2, 3, 4)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4); } { ITuple4_Float v = VectorUtils.Convert <ITuple4_Float>(new BuffVector4d(1, 2, 3, 4)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4); } { ITuple4_Byte v = VectorUtils.Convert <ITuple4_Byte>(new BuffVector4d(1, 2, 3, 4)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4); } // 4D - points { ITuple4_Float v = VectorUtils.Convert <ITuple4_Float>(new Point4d(1, 2, 3, 4)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4); } { ITuple4_Byte v = VectorUtils.Convert <ITuple4_Byte>(new Point4d(1, 2, 3, 4)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4); } { ITuple4_Float v = VectorUtils.Convert <ITuple4_Float>(new BuffPoint4d(1, 2, 3, 4)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4); } { ITuple4_Byte v = VectorUtils.Convert <ITuple4_Byte>(new BuffPoint4d(1, 2, 3, 4)); Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4); } }
bool IEquatable <IColor4> .Equals(IColor4 other) { ITuple4_Float _other = other.AsTupleFloat(); return(this.Equals(_other.X, _other.Y, _other.Z, _other.W)); }
bool IEpsilonEquatable <IColor4> .EpsilonEquals(IColor4 other, double epsilon) { ITuple4_Float _other = other.AsTupleFloat(); return(this.EpsilonEquals(_other.X, _other.Y, _other.Z, _other.W, (float)epsilon)); }