Esempio n. 1
0
		public void CannotSetPercentagesToInconsistentValues()
		{
			var colors = new List<Color>(new[] { Color.Orange, Color.PaleGreen, Color.Gold });
			var colorsTimeRange = new TimeRangeGraph<Color>(colors);
			Assert.IsFalse(
				colorsTimeRange.TrySetAllPercentagesNoOrderChange(new List<float>(new[] { 0.0f })));
			Assert.IsFalse(
				colorsTimeRange.TrySetAllPercentagesNoOrderChange(
					new List<float>(new[] { 0.1f, 1.0f, 0.2f })));
		}
        public void CannotSetPercentagesToInconsistentValues()
        {
            var colors          = new List <Color>(new[] { Color.Orange, Color.PaleGreen, Color.Gold });
            var colorsTimeRange = new TimeRangeGraph <Color>(colors);

            Assert.IsFalse(
                colorsTimeRange.TrySetAllPercentagesNoOrderChange(new List <float>(new[] { 0.0f })));
            Assert.IsFalse(
                colorsTimeRange.TrySetAllPercentagesNoOrderChange(
                    new List <float>(new[] { 0.1f, 1.0f, 0.2f })));
        }
Esempio n. 3
0
		public void GetInterpolationValue()
		{
			var points =
				new List<Vector2D>(new[] { Vector2D.UnitX, Vector2D.Zero, Vector2D.One, Vector2D.UnitY });
			var pointsTimeRange = new TimeRangeGraph<Vector2D>(points);
			Assert.IsTrue(
				pointsTimeRange.TrySetAllPercentagesNoOrderChange(
					new List<float>(new[] { 0.0f, 0.2f, 0.7f, 1.0f })));
			const float ExpectedInterpolation = 4.0f / 5.0f;
			Assert.IsTrue(
				pointsTimeRange.GetInterpolatedValue(0.6f).IsNearlyEqual(Vector2D.One *
					ExpectedInterpolation));
			Assert.AreEqual(Vector2D.UnitY, pointsTimeRange.GetInterpolatedValue(1.2f));
			Assert.AreEqual(Vector2D.UnitX, pointsTimeRange.GetInterpolatedValue(-0.1f));
		}
        public void GetInterpolationValue()
        {
            var points =
                new List <Vector2D>(new[] { Vector2D.UnitX, Vector2D.Zero, Vector2D.One, Vector2D.UnitY });
            var pointsTimeRange = new TimeRangeGraph <Vector2D>(points);

            Assert.IsTrue(
                pointsTimeRange.TrySetAllPercentagesNoOrderChange(
                    new List <float>(new[] { 0.0f, 0.2f, 0.7f, 1.0f })));
            const float ExpectedInterpolation = 4.0f / 5.0f;

            Assert.IsTrue(
                pointsTimeRange.GetInterpolatedValue(0.6f).IsNearlyEqual(Vector2D.One *
                                                                         ExpectedInterpolation));
            Assert.AreEqual(Vector2D.UnitY, pointsTimeRange.GetInterpolatedValue(1.2f));
            Assert.AreEqual(Vector2D.UnitX, pointsTimeRange.GetInterpolatedValue(-0.1f));
        }