Example #1
0
 def get_color(self) -> Color:
     if self.tone is not None:
         c = Color()
         c.set_hue(self.tone.get_hue())
         c.set_saturation(0.5)
         c.set_luminance(0.4)
         return c
     if self.color is not None:
         return self.color
     return DEFAULT_COLOR
Example #2
0
import subprocess

from colour import Color


#get primary color from pywal values
color = subprocess.check_output(['grep', 'color1:', '/home/cta/.Xresources'])
color = color.decode().rstrip().split(' ')
print(color)
color = color[-1]

primary_col = Color(color)
print(primary_col.get_saturation(), primary_col.hex)
primary_col.set_saturation(primary_col.get_saturation() - .01)
print(primary_col.get_saturation(), primary_col.hex)
Example #3
0
 def match(self, color: Color, ansi=False) -> ColorPoint:
     lum = map_interval(0, 1, .3, .9, color.get_luminance())
     color.set_luminance(lum)
     sat = map_interval(0, 1, .2, .9, color.get_saturation())
     color.set_saturation(sat)
     return super().match(color)
Example #4
0
 def match(self, color: Color, ansi=False) -> ColorPoint:
     if not ansi:
         return super().match(color)
     color.set_saturation(0.3)
     return super(Gray4Palette, self).match(color)
Example #5
0
    def __init__(self, config):
        tk.Tk.__init__(self)
        self.title('BClock')
        self.className = 'tkbclock'
        self.handles = {}
        if os.name == 'posix':
            self.wm_attributes('-type', 'normal')
        if config['noTitle']:
            self.wm_overrideredirect(True)
        self.resizable(False, False)
        self.wm_attributes('-alpha',
                           config['alpha'] if 'alpha' in config else 0.5)
        self.wm_attributes('-topmost', True)
        self.radius = config['radius'] if 'radius' in config else 60
        self.x_offset = config['xyoffset'] if 'xyoffset' in config else 2
        self.y_offset = config['xyoffset'] if 'xyoffset' in config else 2
        self.xcentre = self.x_offset + self.radius
        self.ycentre = self.y_offset + self.radius
        self.center_dot_radius = 5
        canvasWidth = 2 * self.radius + 2 * self.x_offset
        canvasHeight = 2 * self.radius + 2 * self.y_offset
        windowlocation = config[
            'windowlocation'] if 'windowlocation' in config else "+0+0"
        self.geometry(
            str(canvasWidth) + "x" + str(canvasHeight) + windowlocation)
        self.w = tk.Canvas(self,
                           width=canvasWidth,
                           height=canvasHeight,
                           bg=config['backgroundColor']
                           if 'backgroundColor' in config else 'Cyan')
        self.w.pack()
        # Main circle
        self.w.create_oval(self.x_offset, self.y_offset,
                           2 * self.radius + self.x_offset,
                           2 * self.radius + self.y_offset)
        self.w.pack()
        # Centre Dot
        self.w.create_oval(
            self.x_offset + self.radius - self.center_dot_radius,
            self.y_offset + self.radius - self.center_dot_radius,
            self.x_offset + self.radius + self.center_dot_radius,
            self.y_offset + self.radius + self.center_dot_radius,
            fill='Black')
        self.w.pack()
        # Second Hand
        # self.w.create_line(0, 0, 0, 0, fill='Blue', width=1, tags='seconds')
        # Minute Hand
        # self.w.create_line(0, 0, 0, 0, fill='Blue', width=2, tags='minute')
        # Hour Hand

        # Drawing hour markings
        hourMarkLength = config[
            'hourMarkLength'] if 'hourMarkLength' in config else 0.1
        hourMarkLength = 1 - hourMarkLength
        hourMarkColor = config[
            'hourMarkColor'] if 'hourMarkColor' in config else 'Red'
        hourMarkWidth = config[
            'hourMarkWidth'] if 'hourMarkWidth' in config else 6
        for i in range(0, 12):
            self.degree = i * 30
            self.w.create_line((self.radius * cos(
                (self.degree * pi) / 180)) + self.xcentre, (self.radius * sin(
                    (self.degree * pi) / 180)) + self.ycentre,
                               ((self.radius * hourMarkLength) * cos(
                                   (self.degree * pi) / 180)) + self.xcentre,
                               ((self.radius * hourMarkLength) * sin(
                                   (self.degree * pi) / 180)) + self.ycentre,
                               fill=hourMarkColor,
                               width=hourMarkWidth)

        # for i in range(0, 60):
        #     # Drawing minute co-orninates
        #     self.degree = i*6
        #     self.w.create_line((self.radius * cos((self.degree*pi)/180)) + 270, (self.radius * sin((self.degree*pi)/180)
        #                                                                          ) + 270, (240 * cos((self.degree*pi)/180)) + 270, (240 * sin((self.degree*pi)/180)) + 270)

        # Draw hour handles
        for i, c in enumerate(config['handles']):
            tag = c['label'] + '_' + str(i)
            self.handles[tag] = c
            self.w.create_line(0,
                               0,
                               0,
                               0,
                               fill=c['colour'],
                               width=c['width'] if 'width' in c else 4,
                               tags=tag)
            color = Color(c['colour'])
            color.set_saturation(0.5)
            self.w.create_line(0,
                               0,
                               0,
                               0,
                               fill=color.get_web(),
                               width=2,
                               tags=tag + '_minute')
            self.w.create_text(self.radius / 5,
                               2 * (i + 1) * 10,
                               text=c['label'],
                               fill=c['colour'],
                               font=('Times New Roman', 10),
                               tags=tag + '_TEXT')
            self.change_clock(tag)