def test_color_range_continuous(): """Test color range objects with continuous colors.""" color_range = ColorRange( [Color(0, 100, 0), Color(100, 200, 100)], [0, 1000]) assert color_range.color(-100) == Color(0, 100, 0) assert color_range.color(0) == Color(0, 100, 0) assert color_range.color(500) == Color(50, 150, 50) assert color_range.color(250) == Color(25, 125, 25) assert color_range.color(1000) == Color(100, 200, 100) assert color_range.color(1100) == Color(100, 200, 100)
def test_color_range_discontinuous(): """Test color range objects with discontinuous colors.""" color_range = ColorRange(continuous_colors=False) color_range.domain = [100, 2000] color_range.colors = [ Color(75, 107, 169), Color(245, 239, 103), Color(234, 38, 0) ] assert color_range.color(99) == Color(75, 107, 169) assert color_range.color(100) == Color(245, 239, 103) assert color_range.color(2000) == Color(245, 239, 103) assert color_range.color(2001) == Color(234, 38, 0)