コード例 #1
0
        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);
        }
コード例 #2
0
        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)));
        }
コード例 #3
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);
        }
コード例 #4
0
        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)));
        }