Beispiel #1
0
 def test_render_should_render_a_buffer_of_colors(self):
     view = View(1, 3)
     colorBuffer = [Color(255, 0, 0), Color(0, 255, 0), Color(0, 0, 255)]
     view.render(colorBuffer)
     assert view.np[0] == (255, 0, 0)
     assert view.np[1] == (0, 255, 0)
     assert view.np[2] == (0, 0, 255)
Beispiel #2
0
    def test_transform_color(self):
        v = {}
        render_interval = 1
        r = Renderer(v, render_interval)
        target_color = Color(255, 255, 255)

        animation_start_time = 0
        animation_length = 10
        easing = "EaseOutBounce"
        r.update(target_color, animation_start_time, animation_length, easing)
        calculated_color = r.transform_color(0.5)
        assert calculated_color == Color(127, 127, 127)
Beispiel #3
0
    def test_calculate_color_should_set_start_color_if_not_started(self):
        v = {}
        render_interval = 1
        r = Renderer(v, render_interval)
        target_color = Color(0, 0, 255)

        animation_start_time = 0
        animation_length = 10
        easing = "EaseOutBounce"
        r.update(target_color, animation_start_time, animation_length, easing)
        r.calculate_color(0)
        assert r.current_color == Color(0, 0, 0)
Beispiel #4
0
 def test_render_color_should_set_all_lights_same_color(self):
     view = View(1, 3)
     RED = Color(255, 0, 0)
     view.render_color(RED)
     assert view.np[0] == (255, 0, 0)
     assert view.np[1] == (255, 0, 0)
     assert view.np[2] == (255, 0, 0)
Beispiel #5
0
 def test_default_color_is_black(self):
     v = {}
     render_interval = 1
     r = Renderer(v, render_interval)
     from lantern.color import Color
     black = Color(0, 0, 0)
     assert r.current_color == black
Beispiel #6
0
 def test_off_should_turn_off_all_lights(self):
     view = View(1, 3)
     RED = Color(255, 0, 0)
     view.render_color(RED)
     view.off()
     assert view.np[0] == (0, 0, 0)
     assert view.np[1] == (0, 0, 0)
     assert view.np[2] == (0, 0, 0)
Beispiel #7
0
    def test_calculate_color_should_calculate_color_if_in_animation(
            self, mocker):
        v = {}
        render_interval = 1
        r = Renderer(v, render_interval)
        target_color = Color(0, 0, 255)

        def mock_calculate(self, position):
            return Color(255, 255, 255)

        mocker.patch('lantern.renderer.Renderer.transform_color',
                     mock_calculate)

        animation_start_time = 0
        animation_length = 10
        easing = "EaseOutBounce"
        r.update(target_color, animation_start_time, animation_length, easing)
        r.calculate_color(0.5)
        assert r.current_color == Color(255, 255, 255)
Beispiel #8
0
 def mock_calculate(self, position):
     return Color(255, 255, 255)