def draw_vertical_rainbow_frame_at(self, time): time %= self._duration_in_miliseconds known_time_points = [0, self._duration_in_miliseconds] known_colors = [self._start_colors, self._end_colors] time_to_interpolate = [time] interpolated_colors = interpolate(known_time_points, known_colors, time_to_interpolate) colors = interpolated_colors[0] left_color = colors[0] right_color = colors[1] self.draw_vertical_rainbow(Color.from_float_array(left_color), Color.from_float_array(right_color))
def _draw_vertical_rainbow(self, known_coordinates, known_colors): coordinates_to_interpolate = generate_range_points( 0, self._width - 1, self._width) interpolated_colors = interpolate(known_coordinates, known_colors, coordinates_to_interpolate) for x in range(self._width): for y in range(self._height): color = Color.from_float_array(interpolated_colors[x]) self._image.putpixel((x, y), color.get_as_tuple())