Example #1
0
def paint_node(node, basecolor):
    """
    Argumentos:

    - color: tuple em formato HSV: `(hue, saturation, value)`
    """

    fillcolor = basecolor.copy()
    bordercolor = hsv_change_brightness(fillcolor, -100)

    fillcolor_rgb = hsv_to_rgb(fillcolor)
    bordercolor_rgb = hsv_to_rgb(bordercolor)

    node.options['color'] = '{0}'.format(bordercolor_rgb)
    node.options['fillcolor'] = '{0}'.format(fillcolor_rgb)
def paint_node(node, basecolor):
    """
    Argumentos:

    - color: tuple em formato HSV: `(hue, saturation, value)`
    """

    fillcolor = basecolor.copy()
    bordercolor = hsv_change_brightness(fillcolor, -100)

    fillcolor_rgb = hsv_to_rgb(fillcolor)
    bordercolor_rgb = hsv_to_rgb(bordercolor)

    node.options['color'] = '{0}'.format(bordercolor_rgb)
    node.options['fillcolor'] = '{0}'.format(fillcolor_rgb)
Example #3
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)
Example #4
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)})
Example #5
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)})
        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)
Example #7
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)
Example #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)})
Example #9
0
stats_button = Button(
    colors.red,
    colors.light_red,
    1010,
    10,
    260,
    35,
    "Multiplayer Stats",
    font=30,
    padding=0,
    on_click=show_stats,
)

rainbow_button = Button(
    colors.hsv_to_rgb(1.0, 1, 1),
    colors.hsv_to_rgb(1.0, 0.5, 1),
    275,
    550,
    750,
    125,
    "Rainbow Playground",
    font=70,
    padding=0,
    on_click=rainbow_playground,
)

rainbow_help_button = Button(
    colors.hsv_to_rgb(1.0, 1, 1),
    colors.hsv_to_rgb(1.0, 0.5, 1),
    400,