Ejemplo n.º 1
0
 def test_lighting_with_pattern_applied(self):
     m = Material()
     m.pattern = StripePattern(Color.white(), Color.black())
     m.ambient = 1
     m.diffuse = 0
     m.specular = 0
     eyev = Vector(0, 0, -1)
     normalv = Vector(0, 0, -1)
     light = PointLight(Point(0, 0, -10), Color.white())
     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)
     assert c1 == Color.white()
     assert c2 == Color.black()
Ejemplo n.º 2
0
def test_lighting_pattern():
    s = Sphere()
    m = Material()
    m.pattern = StripePattern(Color(1, 1, 1), Color(0, 0, 0))
    m.ambient = 1
    m.diffuse = 0
    m.specular = 0
    eyev = Vector(0, 0, -1)
    normalv = Vector(0, 0, -1)
    light = PointLight(Point(0, 0, -10), Color(1, 1, 1))
    c1 = m.lighting(s, light, Point(0.9, 0, 0), eyev, normalv, False)
    c2 = m.lighting(s, light, Point(1.1, 0, 0), eyev, normalv, False)
    assert c1 == Color(1, 1, 1)
    assert c2 == Color(0, 0, 0)