public void T04_StripeTransformation() { if (Scene.current != null) { Scene.current.Clear(); } Sphere sphere = new Sphere(); sphere.SetMatrix(Mat4.ScaleMatrix(2, 2, 2)); StripePattern pattern = new StripePattern(new SolidColorPattern(Color.white), new SolidColorPattern(Color.black)); Color color = pattern.PatternAtObject(sphere, new Point(1.5, 0, 0)); Assert.AreEqual(Color.white, color); sphere.SetMatrix(new Mat4()); pattern.matrix = Mat4.ScaleMatrix(2, 2, 2); color = pattern.PatternAtObject(sphere, new Point(1.5, 0, 0)); Assert.AreEqual(Color.white, color); sphere.SetMatrix(Mat4.ScaleMatrix(2, 2, 2)); pattern.matrix = Mat4.TranslateMatrix(0.5, 0, 0); color = pattern.PatternAtObject(sphere, new Point(2.5, 0, 0)); Assert.AreEqual(Color.white, color); }
public void AStripePatternIsConstantInY() { var shape = new Sphere(); var pattern = new StripePattern(Color.WHITE, Color.BLACK); Assert.AreEqual(Color.WHITE, pattern.PatternAtObject(shape, new Point(0, 0, 0))); Assert.AreEqual(Color.WHITE, pattern.PatternAtObject(shape, new Point(0, 1, 0))); Assert.AreEqual(Color.WHITE, pattern.PatternAtObject(shape, new Point(0, 2, 0))); }
public void StripesWithAPatternTransformation() { var shape = new Sphere(); var pattern = new StripePattern(Color.WHITE, Color.BLACK) { Transform = Transform.Scaling(2, 2, 2) }; var c = pattern.PatternAtObject(shape, new Point(1.5, 0, 0)); Assert.AreEqual(Color.WHITE, c); }
public void AStripePatternIsAlternatesInX() { var shape = new Sphere(); var pattern = new StripePattern(Color.WHITE, Color.BLACK); Assert.AreEqual(Color.WHITE, pattern.PatternAtObject(shape, new Point(0, 0, 0))); Assert.AreEqual(Color.WHITE, pattern.PatternAtObject(shape, new Point(0.9, 0, 0))); Assert.AreEqual(Color.BLACK, pattern.PatternAtObject(shape, new Point(1, 0, 0))); Assert.AreEqual(Color.BLACK, pattern.PatternAtObject(shape, new Point(-0.1, 0, 0))); Assert.AreEqual(Color.BLACK, pattern.PatternAtObject(shape, new Point(-1, 0, 0))); Assert.AreEqual(Color.WHITE, pattern.PatternAtObject(shape, new Point(-1.1, 0, 0))); }