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()
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)
# at: [ -400, 50, -10 ] # intensity: [ 0.2, 0.2, 0.2 ] # # ====================================================== # # define some constants to avoid duplication # # ====================================================== # - define: white-material # value: # color: [ 1, 1, 1 ] # diffuse: 0.7 # ambient: 0.1 # specular: 0.0 # reflective: 0.1 white = Material() white.color = Color(1, 1, 1) white.diffuse = 0.7 white.ambient = 0.1 white.specular = 0.0 white.reflective = 0.1 # - define: blue-material # extend: white-material # value: # color: [ 0.537, 0.831, 0.914 ] blue = copy.deepcopy(white) blue.color = Color(0.537, 0.831, 0.914) # - define: red-material # extend: white-material # value: # color: [ 0.941, 0.322, 0.388 ] red = copy.deepcopy(white)
def test_assign_material(): s = _TestShape() m = Material() m.ambient = 1 s.set_material(m) assert s.material == m