本文整理汇总了Python中palette.Palette类的典型用法代码示例。如果您正苦于以下问题:Python Palette类的具体用法?Python Palette怎么用?Python Palette使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Palette类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
self.palette = None
self.color = Color()
self.h_ids = {}
self.color.connect("changed", self.color_changed)
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()
示例2: __init__
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()
示例3: __save_clicked
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()
pal.save_via_dialog(title=_("Save mask as a Gimp palette"), parent=self, preview=preview)
示例4: init
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)
示例5: update_files
def update_files(ifs_files, args):
palette = None
if args.palette:
palette = Palette.from_open_file(args.palette)
for ifs_file in ifs_files:
g = pyifs.Generator.from_file(ifs_file)
if args.iterations:
g.iterations = args.iterations
if args.points:
g.num_points = args.points
if args.scale:
g.scale = args.scale
if args.gamma:
g.gamma = args.gamma
if args.zoom:
g.ifs.d = args.zoom
if args.colour or palette:
g.ifs.transforms = [(p, t.get_mutated_colour(palette=palette) ) for (p,t) in g.ifs.transforms]
if args.saturation:
adjust_saturation(g, args.saturation)
f = open(ifs_file, 'w')
f.write(repr(g))
f.truncate()
f.close()
示例6: add_color
def add_color(my, name, palette_key, modifier=0, default=None):
from palette import Palette
palette = Palette.get()
color = palette.color(palette_key, modifier, default=default)
my.add_style("%s: %s" % (name, color))
return color
示例7: __load_clicked
def __load_clicked(self, button):
preview = HCYMaskPreview()
preview.set_size_request(128, 128)
pal = Palette.load_via_dialog(title=_("Load mask from a Gimp palette"), parent=self, preview=preview)
if pal is None:
return
self.editor.set_mask_from_palette(pal)
示例8: _init
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()
示例9: get_gradient
def get_gradient(my, palette_key, modifier=0, range=-20, reverse=False, default=None,angle=180):
from palette import Palette
from web_container import WebContainer
web = WebContainer.get_web()
palette = Palette.get()
if web.is_IE():
color = palette.color(palette_key, (modifier+range)/2, default=default)
return color
else:
if not reverse:
color1 = palette.color(palette_key, modifier, default=default)
color2 = palette.color(palette_key, modifier+range, default=default)
else:
color2 = palette.color(palette_key, modifier, default=default)
color1 = palette.color(palette_key, modifier+range, default=default)
"""
if web.get_browser() == 'Mozilla':
gradient = "-moz-linear-gradient(top, %s, %s)" % (color1, color2)
else:
gradient = "-webkit-gradient(linear, 0%% 0%%, 0%% 100%%, from(%s), to(%s))" % (color1, color2)
"""
gradient = "linear-gradient(%sdeg, %s, %s)" % (angle, color1, color2)
return gradient
示例10: generate_ifs
def generate_ifs():
ifs = IFS(d=3.0)
p = Palette.from_file("/Users/efredine/Pictures/Vancouver/_MG_4051.ptl") # blue and gold
# p = Palette.from_file('/Users/efredine/Pictures/Vancouver/_MG_4306.ptl') #subdued
for n in range(NUM_TRANSFORMS):
transform = random.choice(TRANSFORM_CHOICES)
ifs.add(transform.get_new_transform(params={"palette": p}))
return ifs
示例11: getPalettesFromBankData
def getPalettesFromBankData(self):
assert(self.PALETTE_COLOR_AMOUNT > 0)
assert(self.PALETTE_AMOUNT > 0)
paletteList = []
pointer = 0
for palNum in range(0, self.PALETTE_AMOUNT):
pal = Palette(False)
for colorNum in range(0, self.PALETTE_COLOR_AMOUNT):
B = ((self.data[pointer+1] & 0b01111100) >> 2)
G = (((self.data[pointer+1] & 0b00000011) << 3) + ((self.data[pointer] & 0b11100000) >> 5))
R = self.data[pointer] & 0b00011111
pal.append(Color(red=R, green=G, blue=B, type=False))
pointer += 2
pal.switchType()
paletteList.append(pal)
self.setPalettes(paletteList)
return self.palettes
示例12: __save_clicked
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)
示例13: __init__
def __init__(self):
#Variáveis para criação da tela
self.SIZE = eval( all_config.data["tamanho_tela"])
self.SCREEN = pygame.display.set_mode(self.SIZE)
self.objWorkArea = Work_Area()
self.objPalette = Palette()
self.objSerial = Serial_Arduino()
self.CLOCK = pygame.time.Clock()
self.file = Arquivos()
#Cria os rects
print "Lista de rects criados para a palette:"
示例14: __init__
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
示例15: __init__
def __init__(self, data=[], hasPalettes=False):
self.data = data
self.bankHasPalettes = hasPalettes
self.palettes = None
if ((self.bankHasPalettes) and (data is not None)):
self.palettes = self.getPalettesFromBankData()
# two hardcoded palettes, not sure where they are in ROM yet
# or why they are part of tilemap's palette selection
hardcodedPalette1 = Palette(True)
hardcodedPalette2 = Palette(True)
for x in range(0, self.PALETTE_COLOR_AMOUNT):
hardcodedPalette1.append(self.COLORS_HARDCODED_1[x])
hardcodedPalette2.append(self.COLORS_HARDCODED_2[x])
self.palettes.append(hardcodedPalette1)
self.palettes.append(hardcodedPalette2)
self.image = None
self.tileAmount = 1024
self.createImage()