Exemplo n.º 1
0
    def set_new_color(
        self,
        red_surrounding,
        surrounding,
        new_cells,
        row_idx,
        col_idx,
        surrounding_color,
    ):
        red_value = 0
        green_value = 0
        blue_value = 0
        hsv_color = []

        for color in surrounding_color:
            red_value += color[0]
        red_value /= len(surrounding_color)

        for color in surrounding_color:
            green_value += color[1]
        green_value /= len(surrounding_color)

        for color in surrounding_color:
            blue_value += color[2]
        blue_value /= len(surrounding_color)

        hsv_color = colors.rgb_to_hsv(red_value, blue_value, green_value)

        new_cells[row_idx][col_idx].color = colors.hsv_to_rgb(
            hsv_color[0], 1, 1)
        def links_generator():
            option_tuples = [(k, v) for k, v in self.options.items()]
            option_strs = ['{0}="{1}"'.format(k, v) for k, v in option_tuples]

            yield '{0} [{1}]'.format(self.name, ','.join(option_strs))

            for linked_node in self.links:

                if 'fillcolor' in self.options and 'fillcolor' in linked_node.options:
                    color_a_hsv = rgb_to_hsv(self.options['fillcolor'])
                    color_b_hsv = rgb_to_hsv(linked_node.options['fillcolor'])

                    average_color_hsv = tuple((a+b)/2 for a, b in zip(color_a_hsv, color_b_hsv))

                    average_color_rgb = hsv_to_rgb(average_color_hsv)


                    edge_options = 'color = "{}"'.format(average_color_rgb)

                yield '{0} -- {1} [{2}]'.format(self.name, linked_node.name, edge_options)
Exemplo n.º 3
0
        def links_generator():
            option_tuples = [(k, v) for k, v in self.options.items()]
            option_strs = ['{0}="{1}"'.format(k, v) for k, v in option_tuples]

            yield '{0} [{1}]'.format(self.name, ','.join(option_strs))

            for linked_node in self.links:

                if 'fillcolor' in self.options and 'fillcolor' in linked_node.options:
                    color_a_hsv = rgb_to_hsv(self.options['fillcolor'])
                    color_b_hsv = rgb_to_hsv(linked_node.options['fillcolor'])

                    average_color_hsv = tuple(
                        (a + b) / 2 for a, b in zip(color_a_hsv, color_b_hsv))

                    average_color_rgb = hsv_to_rgb(average_color_hsv)

                    edge_options = 'color = "{}"'.format(average_color_rgb)

                yield '{0} -- {1} [{2}]'.format(self.name, linked_node.name,
                                                edge_options)
def make_node(name, group_index, config):
    group_options = cfg('groups.{}'.format(group_index), config)

    node = Node(name)
    node.options['label'] = ''

    basecolor_rgb = cfg('basecolor', group_options)
    brightness_offset = cfg('brightness_offset', group_options)

    basecolor_hsv = rgb_to_hsv(basecolor_rgb)

    changed_basecolor_hsv = hsv_change_brightness(basecolor_hsv, brightness_offset)

    paint_node(node, changed_basecolor_hsv)

    return node
Exemplo n.º 5
0
def make_node(name, group_index, config):
    group_options = cfg('groups.{}'.format(group_index), config)

    node = Node(name)
    node.options['label'] = ''

    basecolor_rgb = cfg('basecolor', group_options)
    brightness_offset = cfg('brightness_offset', group_options)

    basecolor_hsv = rgb_to_hsv(basecolor_rgb)

    changed_basecolor_hsv = hsv_change_brightness(basecolor_hsv,
                                                  brightness_offset)

    paint_node(node, changed_basecolor_hsv)

    return node
Exemplo n.º 6
0
 def get_highlight_colors(self):
     entry = self.__entries__.values()[0]
     default_color = gtkcolor_to_rgb(entry.style.bg[gtk.STATE_SELECTED])
     hsv = colors.rgb_to_hsv(*default_color)
     box_s = hsv[1]
     box_v = hsv[2]
     if box_v < 0.5:
         box_v = box_v * 2
     if box_s > 0.75:
         box_s = box_s * 0.5
     else:
         box_s = box_s * 1.5
         if box_s > 1:
             box_s = 1.0
     self.box_color = colors.hsv_to_rgb(hsv[0], box_s, box_v)
     self.box_and_row_color = colors.rotate_hue_rgb(*self.box_color, **{"rotate_by": 0.33 / 2})
     self.row_color = colors.rotate_hue_rgb(*self.box_color, **{"rotate_by": 0.33})
     self.col_color = colors.rotate_hue_rgb(*self.box_color, **{"rotate_by": 0.66})
     self.box_and_col_color = colors.rotate_hue_rgb(*self.box_color, **{"rotate_by": 1.0 - (0.33 / 2)})
Exemplo n.º 7
0
 def get_highlight_colors (self):
     bg = self.get_style_context().get_background_color(Gtk.StateFlags.SELECTED)
     default_color = (bg.red, bg.green, bg.blue)
     hsv = colors.rgb_to_hsv(*default_color)
     box_s = hsv[1]
     box_v = hsv[2]
     if box_v < 0.5:
         box_v = box_v * 2
     if box_s > 0.75:
         box_s = box_s * 0.5
     else:
         box_s = box_s * 1.5
         if box_s > 1:
             box_s = 1.0
     self.box_color = colors.hsv_to_rgb(hsv[0], box_s, box_v)
     self.box_and_row_color = colors.rotate_hue_rgb(*self.box_color, **{'rotate_by': 0.33 / 2})
     self.row_color = colors.rotate_hue_rgb(*self.box_color, **{'rotate_by': 0.33})
     self.col_color = colors.rotate_hue_rgb(*self.box_color, **{'rotate_by': 0.66})
     self.box_and_col_color = colors.rotate_hue_rgb(*self.box_color, **{'rotate_by': 1.0 - (0.33 / 2)})
Exemplo n.º 8
0
 def get_highlight_colors(self):
     entry = self.__entries__.values()[0]
     default_color = gtkcolor_to_rgb(entry.style.bg[gtk.STATE_SELECTED])
     hsv = colors.rgb_to_hsv(*default_color)
     box_s = hsv[1]
     box_v = hsv[2]
     if box_v < 0.5:
         box_v = box_v * 2
     if box_s > 0.75:
         box_s = box_s * 0.5
     else:
         box_s = box_s * 1.5
         if box_s > 1:
             box_s = 1.0
     self.box_color = colors.hsv_to_rgb(hsv[0], box_s, box_v)
     self.box_and_row_color = colors.rotate_hue_rgb(
         *self.box_color, **{'rotate_by': 0.33 / 2})
     self.row_color = colors.rotate_hue_rgb(*self.box_color,
                                            **{'rotate_by': 0.33})
     self.col_color = colors.rotate_hue_rgb(*self.box_color,
                                            **{'rotate_by': 0.66})
     self.box_and_col_color = colors.rotate_hue_rgb(
         *self.box_color, **{'rotate_by': 1.0 - (0.33 / 2)})