public void ColorAt_should_linearly_interpolate_between_colors() { var pattern = new GradientPattern(Colors.White, Colors.Black); pattern.ColorAt(new Point(0, 0, 0)).Should().Be(Colors.White); pattern.ColorAt(new Point(0.25, 0, 0)).Should().Be(new Color(0.75, 0.75, 0.75)); pattern.ColorAt(new Point(0.5, 0, 0)).Should().Be(new Color(0.5, 0.5, 0.5)); pattern.ColorAt(new Point(0.75, 0, 0)).Should().Be(new Color(0.25, 0.25, 0.25)); }
public void TestGradientPatternTransform() { var pattern = new GradientPattern(_white, _black); Assert.AreEqual(_white, pattern.ColorAt(Tuple.Point(0, 0, 0))); Assert.AreEqual(new Color(0.75, 0.75, 0.75), pattern.ColorAt(Tuple.Point(0.25, 0, 0))); Assert.AreEqual(new Color(0.5, 0.5, 0.5), pattern.ColorAt(Tuple.Point(0.5, 0, 0))); Assert.AreEqual(new Color(0.25, 0.25, 0.25), pattern.ColorAt(Tuple.Point(1.75, 0, 0))); }
public void ColorAt() { var pattern = new GradientPattern(Color.White, Color.Black); Assert.Equal(Color.White, pattern.ColorAt(Point.Zero)); Assert.Equal(new Color(0.75f, 0.75f, 0.75f), pattern.ColorAt(new Point(0.25f, 0, 0))); Assert.Equal(new Color(0.5f, 0.5f, 0.5f), pattern.ColorAt(new Point(0.5f, 0, 0))); Assert.Equal(new Color(0.25f, 0.25f, 0.25f), pattern.ColorAt(new Point(0.75f, 0, 0))); Assert.Equal(Color.Black, pattern.ColorAt(new Point(1, 0, 0))); }
private static void TestCase05() { // A gradient linearly interpolates between colors Pattern pattern = new GradientPattern(white, black); Assert.Equal(white, pattern.ColorAt(Tuple.Point(0, 0, 0))); Assert.Equal(Tuple.Color(0.75f, 0.75f, 0.75f), pattern.ColorAt(Tuple.Point(0.25f, 0, 0))); Assert.Equal(Tuple.Color(0.5f, 0.5f, 0.5f), pattern.ColorAt(Tuple.Point(0.5f, 0, 0))); Assert.Equal(Tuple.Color(0.25f, 0.25f, 0.25f), pattern.ColorAt(Tuple.Point(0.75f, 0, 0))); }
public void Linearly_Interpolates_Between_Colors() { var pattern = new GradientPattern(Color.White, Color.Black); var unitSphere = new Sphere(); pattern.ColorAt(new Point(0, 0, 0), unitSphere).ShouldBe(Color.White); pattern.ColorAt(new Point(0.25, 0, 0), unitSphere).ShouldBe(Color.White * .75); pattern.ColorAt(new Point(0.5, 0, 0), unitSphere).ShouldBe(Color.White * .5); pattern.ColorAt(new Point(0.75, 0, 0), unitSphere).ShouldBe(Color.White * .25); }
public void A_gradient_linearly_interpolates_between_colors() { var pattern = new GradientPattern(Color.White, Color.Black); Assert.AreEqual( new Color(1, 1, 1), pattern.ColorAt(Tuple.Point(0, 0, 0))); Assert.AreEqual( new Color(0.75, 0.75, 0.75), pattern.ColorAt(Tuple.Point(0.25, 0, 0))); Assert.AreEqual( new Color(0.5, 0.5, 0.5), pattern.ColorAt(Tuple.Point(0.5, 0, 0))); Assert.AreEqual( new Color(0.25, 0.25, 0.25), pattern.ColorAt(Tuple.Point(0.75, 0, 0))); }