Example #1
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)
Example #2
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
Example #3
0
    def test_calculate_color_should_set_end_color_if_ended(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(1)
        assert r.current_color == target_color
Example #4
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)
Example #5
0
 def test_initialise(self):
     v = {}
     render_interval = 1
     r = Renderer(v, render_interval)
     assert isinstance(r, Renderer)
Example #6
0
 def test_creates_blank_palette(self):
     from lantern.palette import Palette
     v = {}
     render_interval = 1
     r = Renderer(v, render_interval)
     assert isinstance(r.palette, Palette)
Example #7
0
 def test_creates_blank_animation(self):
     from lantern.animation import Animation
     v = {}
     render_interval = 1
     r = Renderer(v, render_interval)
     assert isinstance(r.animation, Animation)
Example #8
0
    def test_default_easing(self):
        v = {}
        render_interval = 1
        r = Renderer(v, render_interval)

        assert r.easing == "ElasticEaseOut"