コード例 #1
0
 def __init__(self, master=None, starting_color=None, **cnf):
     super().__init__(master, **cnf)
     shifts = [
         *[(255, 0, i) for i in range(256)],  # Magenta shift
         *[(255 - i, 0, 255) for i in range(256)],  # Blue shift
         *[(0, i, 255) for i in range(256)],  # Cyan shift
         *[(0, 255, 255 - i) for i in range(256)],  # Green shift
         *[(i, 255, 0) for i in range(256)],  # Yellow shift
         *[(255, 255 - i, 0) for i in range(256)],  # Red shift
     ]
     hsv_start = color.to_hsv(color.to_rgb(starting_color or "#000000"))
     self.configure(**self.style.surface)
     self.col = _ColorSpace(self, hsv_start[0])
     self.col.pack()
     self.hue = hue = _ColorStrip(self, shifts)
     hue.pack()
     hue.on_change(self.adjust_strips)
     hue.on_implicit_change(self.recolor_strips)
     self.col.on_change(self.update_panel)
     self.monitor = monitor = panels.ColorInput(self)
     self.monitor.on_change(self.on_monitor_change)
     monitor.pack()
     self._on_change = None
コード例 #2
0
ファイル: panels.py プロジェクト: ObaraEmmanuel/Formation
 def set(self, hex_str: str) -> None:
     h, s, v = to_hsv(to_rgb(hex_str))
     self.h.set(round(h))
     self.s.set(round(s))
     self.v.set(round(v))
     self.initial = hex_str
コード例 #3
0
 def recolor_strips(self, rgb):
     h, *_ = color.to_hsv(rgb)
     self.col.recolor(h)
コード例 #4
0
 def set_strips(self, hex_string):
     h, s, v = color.to_hsv(color.to_rgb(hex_string))
     # Since the hue color strip is using preset color shifts it is reversed with 0 on the right and 360 on the left
     # We therefore need to use the complement of the fraction 1 - f
     self.hue.set(1 - h / 360)
     self.col.set(s / 100, v / 100)
コード例 #5
0
 def get_hsv(self):
     return color.to_hsv(self.get())