public void ChangingScale() { var parent = new ScaledPositionedObject { ScaleX = .5f, ScaleY = .5f }; var polygon = new ScaledPolygon { X = 10, Y = 10, Points = new List<Point> { new Point(0, 0), new Point(32, 0), new Point(32, 32), new Point(0, 32), new Point(0, 0) } }; polygon.AttachTo(parent, true); polygon.UpdateDependencies(1.0); polygon.RelativeScaleX = .5f; polygon.RelativeScaleY = .5f; polygon.UpdateDependencies(2.0); Assert.IsTrue(Math.Abs(polygon.Points[0].X) < Single.Epsilon); Assert.IsTrue(Math.Abs(polygon.Points[1].X - 8f) < Single.Epsilon); Assert.IsTrue(Math.Abs(polygon.Points[2].X - 8f) < Single.Epsilon); Assert.IsTrue(Math.Abs(polygon.Points[3].X) < Single.Epsilon); Assert.IsTrue(Math.Abs(polygon.Points[4].X) < Single.Epsilon); Assert.IsTrue(Math.Abs(polygon.Points[0].Y) < Single.Epsilon); Assert.IsTrue(Math.Abs(polygon.Points[1].Y) < Single.Epsilon); Assert.IsTrue(Math.Abs(polygon.Points[2].Y - 8f) < Single.Epsilon); Assert.IsTrue(Math.Abs(polygon.Points[3].Y - 8f) < Single.Epsilon); Assert.IsTrue(Math.Abs(polygon.Points[4].Y) < Single.Epsilon); }
public void ParentScaleAffectsPosition() { var parent = new ScaledPositionedObject { ScaleX = .5f, ScaleY = .5f }; var polygon = new ScaledPolygon { X = 10, Y = 15, Points = new List<Point> { new Point(0, 0), new Point(32, 0), new Point(32, 32), new Point(0, 32), new Point(0, 0) } }; polygon.AttachTo(parent, true); polygon.UpdateDependencies(1.0); polygon.UpdateDependencies(2.0); Assert.IsTrue(Math.Abs(polygon.X - 5f) < Single.Epsilon); Assert.IsTrue(Math.Abs(polygon.Y - 7.5f) < Single.Epsilon); }