Esempio n. 1
0
 def test_insterpolate(self):
     self.assertEqual(
         color.interpolate_rgb((45, 76, 76), (100, 142, 123), 0.1),
         (50, 82, 80))
     self.assertEqual(
         color.interpolate_rgb((76, 70, 61), (127, 40, 81), 0.7),
         (111, 49, 75))
     self.assertEqual(
         color.interpolate_hsb((0.4, 0.76, 0.76), (0.1, 0.14, 0.12), 0.1),
         (0.37, 0.698, 0.696))
     self.assertEqual(
         color.interpolate_hsb((0.7, 0.7, 0.1), (0.12, 0.4, 0.8), 0.7),
         (0.294, 0.49, 0.59))
Esempio n. 2
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
Esempio n. 3
0
 def get_color(self):
     t = 1.0 - (self.final_time - seconds()) / self.duration
     t = min(1.0, self.interpolator(t))
     return interpolate_rgb(self.begin_color(), self.end_color(), t)
Esempio n. 4
0
 def get_color(self):
     t = 1.0 - (self.final_time - seconds()) / self.duration
     t = min(1.0, self.interpolator(t))
     return interpolate_rgb(self.begin(), self.end(), t)