Esempio n. 1
0
    def create_dock_widgets(self):
        # Palette widget
        palette = QtGui.QDockWidget('palette', self)
        palette.setAllowedAreas(Qt.RightDockWidgetArea)
        palette.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures)
        palette.setWidget(Palette(self.context, self.signals))
        palette.setSizePolicy(QtGui.QSizePolicy.Preferred,
                              QtGui.QSizePolicy.Minimum)
        self.addDockWidget(Qt.RightDockWidgetArea, palette)

        # Global properties
        curve_properties = CurveProperties('curve properties', self.context,
                                           self.signals)
        curve_properties.setSizePolicy(QtGui.QSizePolicy.Maximum,
                                       QtGui.QSizePolicy.Maximum)
        self.addDockWidget(Qt.RightDockWidgetArea, curve_properties)

        # Tool Properties widget
        tool_properties = ToolProperties('tool properties', self.context,
                                         self.signals)
        tool_properties.setSizePolicy(QtGui.QSizePolicy.Preferred,
                                      QtGui.QSizePolicy.Expanding)
        self.addDockWidget(Qt.RightDockWidgetArea, tool_properties)

        # Curves
        curve_selector = CurveSelector('curve selector', self.context,
                                       self.signals, self)
        curve_selector.setSizePolicy(QtGui.QSizePolicy.Preferred,
                                     QtGui.QSizePolicy.Expanding)
        self.addDockWidget(Qt.RightDockWidgetArea, curve_selector)
Esempio n. 2
0
    def __init__(self):
        self.palette = None
        self.color = Color()
        self.color.connect('changed', self.color_changed)

        self.icon_path = os.path.join(os.path.dirname(__file__), 'data',
                                      'icons')

        self.init_config()
        self.build_gui()

        self.palette_dir = os.path.join(base.save_config_path(appinfo.pkgname),
                                        'palettes')
        Palette.PaletteDir = self.palette_dir

        self.palette_list = PaletteList()
        self.palette_list.load(self.palette_dir)
        self.palette_combo.set_model(self.palette_list)

        # no palettes, so create default
        if len(self.palette_list) == 0:
            palette = Palette()
            palette.name = "Default Palette"
            palette.filename = os.path.join(self.palette_dir, 'default.gpl')
            self.palette_list.append(palette)

            self.palette_combo.select(0)

        self.colorpicker.set_color(self.color)

        self.load_config()
Esempio n. 3
0
    def createDockWidgets(self):

        # Palette widget
        self.palette = QtWidgets.QDockWidget(
            self.context.getText("dock_widgets", "palette"), self)
        self.palette.setAllowedAreas(Qt.RightDockWidgetArea)
        self.palette.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures)

        paletteWidget = Palette(self.context, self.signals)

        self.palette.setWidget(paletteWidget)
        self.palette.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                   QtWidgets.QSizePolicy.Minimum)

        self.addDockWidget(Qt.RightDockWidgetArea, self.palette)

        # Tool Properties widget
        self.toolProperties = ToolProperties(
            self.context.getText("dock_widgets", "tool_properties"),
            self.context, self.signals)
        self.addDockWidget(Qt.RightDockWidgetArea, self.toolProperties)
        self.toolProperties.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                          QtWidgets.QSizePolicy.Expanding)

        # Preview
        self.preview = Preview(self.context.getText("dock_widgets", "preview"),
                               self.context, self.signals, self)
        self.addDockWidget(Qt.RightDockWidgetArea, self.preview)
Esempio n. 4
0
def main():
    args = sys.argv

    if not validate_command_line_args(args):
        return

    json_file_name = args[1]
    if len(args) == 2:
        generate_png = False
        png_file_name = None
    else:
        generate_png = True
        png_file_name = args[3]

    try:
        data_to_draw = JsonParser(json_file_name)
    except IOError as err:
        print(err)
        return

    palette = Palette(data_to_draw.get_palette())
    screen = Screen(data_to_draw.get_screen())
    figures = []

    for figure in data_to_draw.get_figures():
        try:
            figures.append(create_figure_obj(figure))
        except Exception as err:
            print(err)

    canvas = PyGameCanvas(palette, screen, figures)
    canvas.run_pygame(generate_png, png_file_name)

    return
Esempio n. 5
0
 def choose_palette(self, palette_file):
     palette_file = Palette.get_abs_path(palette_file)
     if palette_file:
         self.palette = Palette(palette_file)
         self.update_image()
         self.update_actions()
         self.palette_window = ColorRampWidget(self.palette)
Esempio n. 6
0
    def extend_color(self, color_data, palette):
        """
        :param color_data:
        :param palette:
        :return: palette, data_index
        """

        color_set = set()
        for color in color_data:
            color_set.add(color)

        if palette.can_extend(color_set):
            return palette, palette.extend(color_data)

        for pal in self._palettes:
            if pal is palette:
                continue
            if pal.can_extend(color_set):
                return pal, pal.extend(color_data)

        palette = Palette(self, 'palette_%d' % (len(self._palettes) + 1), [])
        self.add_palette(palette)
        if palette.can_extend(color_set, 65536):
            return palette, palette.extend(color_data)

        assert False
Esempio n. 7
0
 def getPalette(self, pid):
     # print(pid)
     data = self.client.hgetall("palette:" + pid)
     lerp = (data[b'lerp'].decode('utf-8') == "true")
     colors = self.client.lrange("palette:" + pid + ":colors", 0, -1)
     in_palette = []
     for color in colors:
         in_palette.append(color.decode('utf-8'))
     return Palette(colors=in_palette, lerp=lerp)
Esempio n. 8
0
 def __init__(self, lid, layer={}, palette=0):
     #print(layer)
     self.lid = lid
     self.params = layer
     # print(self.params)
     if palette == 0:
         self.palette = Palette()
     else:
         self.palette = palette
Esempio n. 9
0
def _palette_loadsave_dialog_update_preview_cb(dialog, preview):
    """Updates the preview widget when loading/saving palettes via dialog"""
    filename = dialog.get_preview_filename()
    palette = None
    if filename is not None and os.path.isfile(filename):
        try:
            palette = Palette(filename=filename)
        except Exception, ex:
            logger.warning("Couldn't update preview widget: %s", str(ex))
            return
Esempio n. 10
0
def get_constants():
    window_title = 'PyRogue'

    screen_width = 80
    screen_height = 50

    bar_width = 20
    panel_height = 7
    panel_y = screen_height - panel_height

    message_x = bar_width + 12
    message_width = screen_width - bar_width - 2
    message_height = panel_height - 1

    map_width = 80
    map_height = 43

    room_max_size = 10
    room_min_size = 6
    max_rooms = 30

    fov_algorithm = 0
    fov_light_walls = True
    fov_radius = 10

    max_monsters_per_room = 3
    max_items_per_room = 2

    colors = Palette()

    constants = {
        'window_title': window_title,
        'screen_width': screen_width,
        'screen_height': screen_height,
        'bar_width': bar_width,
        'panel_height': panel_height,
        'panel_y': panel_y,
        'message_x': message_x,
        'message_width': message_width,
        'message_height': message_height,
        'map_width': map_width,
        'map_height': map_height,
        'room_max_size': room_max_size,
        'room_min_size': room_min_size,
        'max_rooms': max_rooms,
        'fov_algorithm': fov_algorithm,
        'fov_light_walls': fov_light_walls,
        'fov_radius': fov_radius,
        'max_monsters_per_room': max_monsters_per_room,
        'max_items_per_room': max_items_per_room,
        'colors': colors
    }

    return constants
Esempio n. 11
0
    def init(self):
        # get screen
        win = self['main_window']
        screen = win.get_screen()
        print screen.get_width(), screen.get_height()

        self.current_window = None

        self.move(0, 0)
        #print self.get_position()

        palette = Palette(self)
        palette.show()

        vbox = self['vbox']
        hpaned = gtk.HPaned()
        hpaned.show()
        win.remove(vbox)
        hpaned.pack1(vbox, shrink=False)
        hpaned.pack2(palette.toplevel())
        hpaned.set_property('position', 300)

        vbox0 = gtk.VBox()
        vbox0.pack_start(hpaned, expand=False)
        centerbox = gtk.HBox()
        centerbox.show()
        vbox0.pack_start(centerbox)
        vbox0.show()
        win.add(vbox0)

        browser = Browser(self)
        browser.show()
        centerbox.pack_start(browser.toplevel(), expand=False)
        self.tree = WidgetTree(self)
        obtreeview = self.tree['treeview']
        self.tree.remove(obtreeview)
        browser.toplevel().append_page(obtreeview)
        #self.tree.move(0, self.get_height()+60)
        self.tree.hide()

        editor = Editor(self)
        editor.show()
        centerbox.pack_start(editor.toplevel())

        propertybrowser = PropertyBrowser(self)
        self.propertybrowser = propertybrowser
        pbnotebook = propertybrowser['notebook']
        propertybrowser.toplevel().remove(pbnotebook)
        centerbox.pack_start(pbnotebook, expand=False)
        propertybrowser.hide()

        self['toolbar'].set_style(gtk.TOOLBAR_ICONS)
Esempio n. 12
0
    def __init__(self, prefs, datapath):
        """Initialises with default colors and an empty adjuster list.

        :param prefs: Prefs dict for saving settings.
        :param datapath: Base path for saving palettes and masks.

        """
        gobject.GObject.__init__(self)

        # Defaults
        self._color = None  #: Currently edited color, a UIColor object
        self._hist = []  #: List of previous colors, most recent last
        self._palette = None  #: Current working palette
        self._adjusters = weakref.WeakSet()  #: The set of registered adjusters
        self._picker_cursor = gdk.Cursor(gdk.CROSSHAIR)  #: Cursor for pickers
        self._datapath = datapath  #: Base path for saving palettes and masks
        self._hue_distorts = None  #: Hue-remapping table for color wheels
        self._prefs = prefs  #: Shared preferences dictionary

        # Build the history. Last item is most recent.
        hist_hex = list(prefs.get(PREFS_KEY_COLOR_HISTORY, []))
        hist_hex = self._DEFAULT_HIST + hist_hex
        self._hist = [RGBColor.new_from_hex_str(s) for s in hist_hex]
        self._trim_hist()

        # Restore current color, or use the most recent color.
        col_hex = prefs.get(PREFS_KEY_CURRENT_COLOR, None)
        if col_hex is None:
            col_hex = hist_hex[-1]
        self._color = RGBColor.new_from_hex_str(col_hex)

        # Initialize angle distort table
        wheel_type = prefs.get(PREFS_KEY_WHEEL_TYPE, self._DEFAULT_WHEEL_TYPE)
        distorts_table = self._HUE_DISTORTION_TABLES[wheel_type]
        self._hue_distorts = distorts_table

        # Initialize working palette
        palette_dict = prefs.get(PREFS_PALETTE_DICT_KEY, None)
        if palette_dict is not None:
            palette = Palette.new_from_simple_dict(palette_dict)
        else:
            datapath = self.get_data_path()
            palettes_dir = os.path.join(datapath, DATAPATH_PALETTES_SUBDIR)
            default = os.path.join(palettes_dir, DEFAULT_PALETTE_FILE)
            palette = Palette(filename=default)
        self._palette = palette

        # Capture updates to the working palette
        palette.info_changed += self._palette_changed_cb
        palette.match_changed += self._palette_changed_cb
        palette.sequence_changed += self._palette_changed_cb
        palette.color_changed += self._palette_changed_cb
Esempio n. 13
0
    def get_colors(self,
                   image_path,
                   num,
                   return_color_counts=False,
                   return_image=False,
                   use_logs=False):
        if num < 2:
            print("The image must have at least 2 colors.")
            return
        image = cv2.imread(image_path, cv2.IMREAD_COLOR)
        (h, w) = image.shape[:2]
        # Convert color spaces
        image = cv2.cvtColor(image, cv2.COLOR_BGR2LAB)
        image = image.reshape((image.shape[0] * image.shape[1], 3))
        clusters = MiniBatchKMeans(n_clusters=num)
        labels = clusters.fit_predict(image)
        res = clusters.cluster_centers_.astype("uint8")[labels]
        # To get the colors back to RGB, we must convert to an image and extract the colors
        res = res.reshape((h, w, 3))
        res = cv2.cvtColor(res, cv2.COLOR_LAB2BGR)
        if return_image:
            res_image = res

        res = res.reshape((h * w, 3))

        res_colors = []
        color_counts = []

        for color in res:
            string_color = generate_hex(color, bgr=True)
            if string_color not in res_colors:
                res_colors.append(string_color)
                color_counts.append(0)
            else:
                color_counts[res_colors.index(string_color)] += 1

        palette = Palette()
        for i, color in enumerate(res_colors):
            palette.add(Color(color, color_counts[i]))

        self.scheme_cache = palette

        # Oh no
        if return_image:
            if return_color_counts:
                return palette, color_counts, res_image
            return palette, res_image
        if return_color_counts:
            return palette, color_counts
        return palette
Esempio n. 14
0
    def __init__(self, app):

        gtk.Window.__init__(self)
        self.app = app

        vbox = gtk.VBox(False, 0)

        self.mb = AppMenubar(self)
        vbox.pack_start(self.mb, False, False, 0)

        self.toolbar = AppToolbar(self)
        vbox.pack_start(self.toolbar, False, False, 0)

        #---CENTRAL PART
        hbox = gtk.HBox(False, 0)
        self.tools_frame = gtk.EventBox()
        self.tools = AppTools(self)
        hbox.pack_start(self.tools_frame, False, False, 1)

        self.nb_frame = gtk.EventBox()
        self.nb_splash = SplashArea(self)
        hbox.pack_start(self.nb_frame, True, True, 1)

        self.nb = gtk.Notebook()
        self.nb_frame.add(self.nb_splash)
        self.nb.connect('switch-page', self.change_doc)
        self.nb.set_property('scrollable', True)

        vbox.pack_start(hbox, True, True, 2)
        #---CENTRAL PART

        self.statusbar = AppStatusbar(self)
        vbox.pack_end(self.statusbar, expand=False)

        self.palette = Palette(self)
        vbox.pack_end(self.palette, False, False, 0)

        self.add(vbox)
        self.set_win_title()
        self.set_size_request(config.mw_min_width, config.mw_min_height)
        self.set_default_size(config.mw_width, config.mw_height)
        self.set_position(gtk.WIN_POS_CENTER)
        self.connect("delete-event", self.exit)
        self.add_accel_group(self.app.accelgroup)
        icon = os.path.join(config.resource_dir, 'app_icon.png')
        self.set_icon_from_file(icon)
        self.show_all()
        if config.mw_maximized:
            self.window.maximize()
Esempio n. 15
0
def run_open():
    try:
        open_app.close()
        open_app.deleteLater()
    except:
        pass

    open_app = OpenDialog()
    open_app.setParent(parentHou, QtCore.Qt.Window)

    open_app.setStyle(QtWidgets.QStyleFactory.create("fusion"))
    dark_palette = QtGui.QPalette()
    Palette(dark_palette)
    open_app.setPalette(dark_palette)

    open_app.show()
Esempio n. 16
0
    def __init__(self, root):
        self.root = root
        self.writer = Writer()
        w = root.winfo_screenwidth() // 2
        root.geometry(f"{w}x800+{w // 4 * 3}+100")
        root.title("")

        top = Toplevel(root)
        Palette(top).place(relx=0, rely=0, relheight=1, relwidth=1)

        self.board = Board(root, height=800, width=w)
        self.board.pack(fill="both", expand=True)

        self.manager = Manager(root, self.writer, self.root, bg="#435661", height=800, width=w // 5 * 2)
        self.manager.geometry("+250+100")

        self.set_bind()
Esempio n. 17
0
def palette_load_via_dialog(title, parent=None, preview=None,
                            shortcuts=None):
    """Runs a file chooser dialog, returning a palette or `None`.

    The dialog is both modal and blocking. A new `Palette` object is returned
    if the load was successful. The value `None` is returned otherwise.

    :param parent: specifies the parent window
    :param title: dialog title
    :param preview: any preview widget with a ``set_palette()`` method
    :param shortcuts: optional list of shortcut folders

    """
    dialog = Gtk.FileChooserDialog(
        title=title,
        parent=parent,
        action=Gtk.FileChooserAction.OPEN,
        buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
                 Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT),
    )
    if preview is not None:
        dialog.set_preview_widget(preview)
        dialog.connect("update-preview",
                       _palette_loadsave_dialog_update_preview_cb,
                       preview)
    if shortcuts is not None:
        for shortcut in shortcuts:
            dialog.add_shortcut_folder(shortcut)
    dialog.set_do_overwrite_confirmation(True)
    filter = Gtk.FileFilter()
    filter.add_pattern("*.gpl")
    filter.set_name(_("GIMP palette file (*.gpl)"))
    dialog.add_filter(filter)
    filter = Gtk.FileFilter()
    filter.add_pattern("*")
    filter.set_name(_("All files (*)"))
    dialog.add_filter(filter)
    response_id = dialog.run()
    palette = None
    if response_id == Gtk.ResponseType.ACCEPT:
        filename = dialog.get_filename()
        logger.info("Loading palette from %r", filename)
        palette = Palette(filename=filename)
    dialog.destroy()
    return palette
Esempio n. 18
0
 def __save_clicked(self, button):
     pal = Palette()
     mask = self.editor.get_mask()
     for i, shape in enumerate(mask):
         for j, col in enumerate(shape):
             col_name = "mask#%d primary#%d" % (i, j)  # NOT localised
             pal.append(col, col_name)
     preview = HCYMaskPreview()
     preview.set_size_request(128, 128)
     target_mgr = self.target.get_color_manager()
     prefs_ro = deepcopy(target_mgr.get_prefs())
     datapath = target_mgr.get_data_path()
     mgr = ColorManager(prefs=prefs_ro, datapath=datapath)
     preview.set_color_manager(mgr)
     preview.set_managed_color(self.editor.get_managed_color())
     palette_save_via_dialog(pal,
                             title=_("Save mask as a Gimp palette"),
                             parent=self,
                             preview=preview)
Esempio n. 19
0
    def createDockWidgets(self):

        #Palette widget

        self.palette = QDockWidget(self)
        self.palette.setAllowedAreas(Qt.RightDockWidgetArea)
        self.palette.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures)

        palette = Palette(self.context, self.signals)

        self.palette.setWidget(paletteWidget)
        self.palette.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                   QtWidgets.QSizePolicy.Minimum)

        self.addDockWidget(Qt.RightDockWidgetArea, self.palette)

        # image editing widget
        self.ieTools = ieTools(self.context, self.signals)
        self.addDockWidget(Qt.RightDockWidgetArea, self.ieTools)
        self.ieTools.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                   QtWidgets.QSizePolicy.Expanding)
def Main():

    try:
        app.close()
        app.deleteLater()
    except:
        pass

    app = QtWidgets.QApplication(sys.argv)

    app.setStyle(QtWidgets.QStyleFactory.create("fusion"))

    dark_palette = QtGui.QPalette()
    Palette(dark_palette)
    

    app.setPalette(dark_palette)

    ui = MainWindow()
    ui.show()
    sys.exit(app.exec_())
Esempio n. 21
0
 def _init(self):
     """
 Creates the board and palette.
 """
     self._file_name = None
     self._root = Tk()
     self._root.resizable(0, 0)
     self._menu = Menu(self._root, tearoff=0)
     self.board = Board(
         self._root,
         self._menu,
         width=self._board_width,
         height=self._board_height,
         directed_wires=self._directed_wires,
         label_tooltips_enabled=self._label_tooltips_enabled,
         same_label_per_connector=self._same_label_per_connector,
         on_changed=self._on_changed,
         on_exit=self._request_save)
     self._init_board()
     self.palette = Palette(self._root,
                            self.board,
                            width=self._board_width,
                            height=self._palette_height)
     # buttons to change board cursor state
     self.palette.current_left_x -= PALETTE_PADDING
     self._draw_display = self.palette.add_drawable_type(
         Image_Run_Drawable,
         LEFT,
         self._switch_cursor_to_draw,
         image_file=PENCIL_IMAGE)
     self.palette.current_left_x -= PALETTE_PADDING
     self._drag_display = self.palette.add_drawable_type(
         Image_Run_Drawable,
         LEFT,
         self._switch_cursor_to_drag,
         image_file=HAND_IMAGE)
     self.palette.draw_separator()
     self._switch_cursor_to_draw()
Esempio n. 22
0
	def __init__(self, parent):
		wx.Panel.__init__(self, parent, size = (1100,600))
		self.SetBackgroundColour((60,70,100))
		self.SetForegroundColour((255,255,255))

		self.screens_tall = 2
		self.screens_wide = 2
		self.tiles_per_axis = 5

		self.name = 'circleburg'
		self.image_dir = '%s_images' % self.name
		self.savepath = 'saved/%s' % self.name
		self.make_widgets()

		self.position = (0,0)
		self.slides = []

		self.palette = Palette(self, tiles_across=2, tiles_tall=10, full_tile_size=50)

		self.worldmap = Worldmap(self, self.palette, self.screens_wide, self.screens_tall, self.tiles_per_axis)
		self.room_index = (0,0)
		
		self.current_room = self.worldmap.room_grid[self.room_index[0]][self.room_index[1]]
		self.display_window = DisplayWindow(self, height=500, width=800, current_room=self.current_room)

		self.highlighter = self.make_highlighter(1,0,0,5)
		self.avatar = wx.Image('characters/Mr_Circle.png', wx.BITMAP_TYPE_ANY)

		self.current_room.DrawImageAtPosition(self.highlighter, self.position[0], self.position[1])
		self.display_window.refresh()

		self.Bind(wx.EVT_CHAR_HOOK, lambda event: self.onKey(event))

		#self.load_path('saved/circleburg')

		self.refresh()
Esempio n. 23
0
 def setUp(self):
     self.palette = Palette('6081e8', '344283', '251c1e', '775a30')
Esempio n. 24
0
 def append_path(self, path):
     """ Add a palette to the end of the list by specifying its path """
     p = Palette()
     if p.load(path):
         self.append(p)
Esempio n. 25
0
def main():

    # Command line script to make a working example in the main.
    # If you're a recruiter looking for good code practices, avoid this example main and please check the tests and the palette/hex_color modules.
    # Validations in progress. This main is not tested either. Only the modules.

    print(
        "JUST A WARN: This script is gonna open in your browser the EXTERNAL web page colorcombos.com in order to show you the colors. You can close the program to avoid it or follow the rules to continue."
    )
    colorValue = input('Insert a hex color value...')
    color = HexColor(colorValue)
    print(f"{color} is nice!")

    ComboTest(Palette(color)).show()
    print(f"Let's create a Palette from {color}.")
    input('Press enter to continue...')
    palette = PaletteFromColor(color)
    palette.retrieve_matching_hues()

    ComboTest(palette).show()

    print("- " * 10)
    print(f"""Now let's get from your color, three matching ones.
    You'll get your color and two matching more, towards the selected hue.
    
    (If you repeat a channel value, you're going to get less than three, because of the permutation algorithm.)
    
    Choose towards which tone you want to go:
    For example, if you want two blue-ish colors matching yours, write 'b'.
    
    The validation is in progress, so keep in mind that the accepted values are:
    r, g and b (no caps).
    """)

    toneValue = input('Insert r, g or b...')

    trio = TrioFromColor(color)
    trio.choose_hue(toneValue)

    ComboTest(trio).show()

    print("- " * 10)
    print(
        f"""What about being more precise? Let's create a duo from your color.
    You'll get your color and a matching one towards the selected hues.
    
    (If you repeat a channel value, you may get only one, because of the permutation algorithm.)
    
    For example, if you want two red-greenish colors matching yours, write 'rg'.
    The validation is in progress, so keep in mind that the accepted values are:
    rb, gr, gb, br, bg, rg (no caps nor spaces, but they can be in any order).  
    """)

    toneValues = input('Insert two color initials... E.g.: rb')

    duet = DuetFromColor(color)
    duet.choose_hue(toneValues)
    ComboTest(duet).show()

    print("= " * 10)
    print(f"""Now let's play modifying your selected color:
    If we upper the highest channel we get a lighter more saturated color.
    If amount negative, dulls the color.  
    
    Raises an error if the value is > 8. ANd if one of the values reach the max/min, the other one stops in order to get a matching color and not a random one.
    """)

    amountSatChange = input(
        'Insert the amount to change the saturation... E.g.: -4')

    new_color = HexColor(colorValue)
    new_color.additive_saturator(int(amountSatChange))
    satPalette = Palette(color, new_color)
    ComboTest(satPalette).show()
Esempio n. 26
0
    def __init__(self):
        super().__init__()
        camera.orthographic = True
        camera.fov = 100
        window.color = color.white
        self.cursor = Cursor(model=Circle(mode='line'))

        self.canvas_width = 1920
        self.canvas_height = 1080

        # create layer for displaying brush stroke while drawing
        t = time.time()
        self.temp_image = Image.new('RGBA',
                                    (self.canvas_width, self.canvas_height),
                                    (0, 0, 0, 0))
        self.temp_layer = Entity(parent=self,
                                 model='quad',
                                 z=-.1,
                                 color=(1, 1, 1, 1))
        self.temp_texture = Texture(self.temp_image)
        self.temp_layer.texture = self.temp_texture

        self.bg_layer = Layer(self.canvas_width,
                              self.canvas_height,
                              color.white,
                              z=10,
                              enabled=False)
        self.combined_layer = Layer(self.canvas_width,
                                    self.canvas_height,
                                    z=-10,
                                    enabled=False)
        self.combined_layer.outline.color = color.magenta
        print('temp layer:', time.time() - t)

        self.layers = list()
        self.layer_index = -1
        self.layer_index_label = Text(position=window.left, text='-1')
        self.layer_menu = LayerMenu(otoblop=self)
        self.add_layer()

        self.cover = Entity(parent=self.current_layer, z=-1)
        Entity(parent=self.cover,
               model='quad',
               color=color.dark_gray,
               origin_y=-.5,
               y=.5,
               scale=10)
        Entity(parent=self.cover,
               model='quad',
               color=color.dark_gray,
               origin_y=.5,
               y=-.5,
               scale=10)
        Entity(parent=self.cover,
               model='quad',
               color=color.dark_gray,
               origin_x=-.5,
               x=.5,
               scale=10)
        Entity(parent=self.cover,
               model='quad',
               color=color.dark_gray,
               origin_x=.5,
               x=-.5,
               scale=10)
        self.cover.world_parent = self

        # instantiate tools
        self.brush = Brush(parent=self)
        # self.move_tool = MoveTool(parent=self)
        self.eyedropper = Eyedropper(parent=self)
        # self.tools = (self.brush, self.move_tool)
        self.active_tool = self.brush

        self.color_menu = ColorMenu()
        self.palette = Palette(self.brush)

        self.info_text = Text(position=window.top_left,
                              text=dedent('''
                x:   reduce brush size
                d:   increase brush size
                r:   round brush
                p:   paint brush
                1-9: brush opacity
                '''),
                              color=color.black)

        def enable_brush():
            self.brush.enabled = True

        def disable_brush():
            self.brush.enabled = False

        self.move_cursor = Cursor(enabled=False)
        Text(parent=self.move_cursor, text='move', enabled=False)
Esempio n. 27
0
 def test_choose_hue_red_blueish(self):
     expected_addition = 'f0a'
     self.palette.choose_hue('rb')
     self.assertEqual(self.palette, Palette(self.color, expected_addition))
Esempio n. 28
0
 def test_choose_hue_red_greenish(self):
     expected_addition = 'fa0'
     self.palette.choose_hue('rg')
     self.assertEqual(self.palette, Palette(self.color, expected_addition))
Esempio n. 29
0
 def test_choose_hue_if_selected_hue_is_starting_color_return_one_starting_color(
         self):
     self.palette.choose_hue('bg')
     self.assertEqual(self.palette, Palette(self.color))
Esempio n. 30
0
 def test_palette_from_hex_colors(self):
     color1 = HexColor('111')
     color2 = HexColor('222')
     res = str(Palette(color1, color2))
     self.assertEqual(res, 'Palette: #111111 #222222')