Example #1
0
 def update_day_color(self):
     if self.current_time >= 24.00:
         self.current_time = wrap(0.00, 24.00, self.current_time)
     while (self.current_time < self.start_time
            or self.current_time >= self.target_time):
         self.next_color()
         self.target_time = self.target_time or 24.00
     t = ((self.current_time - self.start_time) /
          (self.target_time - self.start_time))
     if self.hsv_transition:
         new_color = interpolate_hsb(self.start_color,
                                     self.target_color, t)
         new_color = hsb_to_rgb(*new_color)
     else:
         new_color = interpolate_rgb(self.start_color,
                                     self.target_color, t)
     if (self.current_color is None
             or rgb_distance(self.current_color, new_color) > 3):
         self.current_color = new_color
         self.set_fog_color(self.current_color)
     self.current_time += self.time_step * self.time_multiplier
Example #2
0
def is_color_dirt(color):
    return rgb_distance(color, DIRT_COLOR) < 30
Example #3
0
def is_color_dirt(color):
    return rgb_distance(color, DIRT_COLOR) < 30
Example #4
0
 def test_distance(self):
     self.assertEqual(color.rgb_distance((1, 2, 3), (9, 8, 7)), 18)