public Color3b(IColor3 other) { ITuple3_Byte _other = other.AsTupleByte(); this.Red = _other.X; this.Green = _other.Y; this.Blue = _other.Z; }
public Color4b(IColor3 other, byte alpha) { ITuple3_Byte _other = other.AsTupleByte(); this.Red = _other.X; this.Green = _other.Y; this.Blue = _other.Z; this.Alpha = alpha; }
public static ITuple3_Byte AsTupleByte(this IColor3 v) { ITuple3_Byte ret = v as ITuple3_Byte; if (ret != null) { return(ret); } return(VectorUtils.Convert <ITuple3_Byte>(v)); }
public void TestConvert_ColorByte() { // Colors { ITuple3_Float v = VectorUtils.Convert <ITuple3_Float>(new Color3b(0, 128, 255)); Assert.IsTrue(v.X.EpsilonEquals(0) && v.Y.EpsilonEquals(0.5f, 0.01f) && v.Z.EpsilonEquals(1)); } { ITuple3_Byte v = VectorUtils.Convert <ITuple3_Byte>(new Color3b(0, 128, 255)); Assert.IsTrue(v.X == 0 && v.Y == 128 && v.Z == 255); } }
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 <IColor3> .Equals(IColor3 other) { ITuple3_Byte _other = other.AsTupleByte(); return(this.Equals(_other.X, _other.Y, _other.Z)); }
bool IEpsilonEquatable <IColor3> .EpsilonEquals(IColor3 other, double epsilon) { ITuple3_Byte _other = other.AsTupleByte(); return(this.EpsilonEquals(_other.X, _other.Y, _other.Z, (byte)epsilon)); }