コード例 #1
0
 def test_a_stripe_pattern_is_constant_in_z(self):
     black = Color(0, 0, 0)
     white = Color(1, 1, 1) 
     p = StripePattern(white, black)
     self.assertTrue(white.equals(p.pattern_at(Point(0, 0, 0))))
     self.assertTrue(white.equals(p.pattern_at(Point(0, 0, 1))))
     self.assertTrue(white.equals(p.pattern_at(Point(0, 0, 2))))
コード例 #2
0
 def test_stripes_with_an_object_transformation(self):
     black = Color(0, 0, 0)
     white = Color(1, 1, 1)
     s = Sphere()
     s.set_transform(scale(2, 2, 2))
     p = StripePattern(white, black)
     c = p.pattern_at_shape(s, Point(1.5, 0, 0))
     self.assertTrue(c.equals(white))
コード例 #3
0
 def test_a_stripe_pattern_alternates_in_x(self):
     black = Color(0, 0, 0)
     white = Color(1, 1, 1)
     p = StripePattern(white, black)
     self.assertTrue(white.equals(p.pattern_at(Point(0, 0, 0))))
     self.assertTrue(white.equals(p.pattern_at(Point(0.9, 0, 0))))
     self.assertTrue(black.equals(p.pattern_at(Point(1, 0, 0))))
     self.assertTrue(black.equals(p.pattern_at(Point(-0.1, 0, 0))))
     self.assertTrue(black.equals(p.pattern_at(Point(-1, 0, 0))))
     self.assertTrue(white.equals(p.pattern_at(Point(-1.1, 0, 0))))
コード例 #4
0
 def test_lighting_with_a_pattern_applied(self):
     sp = StripePattern(Color(1, 1, 1), Color(0, 0, 0))
     m = Material()
     m.pattern = sp
     m.ambient = 1
     m.diffuse = 0
     m.specular = 0
     eyev = Vector(0, 0, -1)
     normalv = Vector(0, 0, -1)
     light = Light(Point(0, 0, -10), Color(1, 1, 1))
     c1 = m.lighting(Sphere(), light, Point(0.9, 0, 0), eyev, normalv,
                     False)
     c2 = m.lighting(Sphere(), light, Point(1.1, 0, 0), eyev, normalv,
                     False)
     self.assertTrue(c1.equals(Color(1, 1, 1)))
     self.assertTrue(c2.equals(Color(0, 0, 0)))
コード例 #5
0
 def test_creating_a_stripe_pattern(self):
     black = Color(0, 0, 0)
     white = Color(1, 1, 1)
     p = StripePattern(white, black)
     p.a = white
     p.b = black