2
# -*- coding: utf-8 -*-
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
21
def palette_offset(palette, amount):
22
#If palette is read only, work on a copy:
23
editable = pdb.gimp_palette_is_editable(palette)
24
if not editable:palette = pdb.gimp_palette_duplicate (palette)
26
num_colors = pdb.gimp_palette_get_info (palette)
29
for i in xrange (num_colors):
30
tmp_entry_array.append ((pdb.gimp_palette_entry_get_name (palette, i),
31
pdb.gimp_palette_entry_get_color (palette, i)))
32
for i in xrange (num_colors):
33
target_index = i + amount
34
if target_index >= num_colors:
35
target_index -= num_colors
36
elif target_index < 0:
37
target_index += num_colors
38
pdb.gimp_palette_entry_set_name (palette, target_index, tmp_entry_array[i][0])
39
pdb.gimp_palette_entry_set_color (palette, target_index, tmp_entry_array[i][1])
44
"python-fu-palette-offset",
45
N_("Offset the colors in a palette"),
46
"palette_offset (palette, amount) -> modified_palette",
47
"Joao S. O. Bueno Calligaris, Carol Spears",
48
"(c) Joao S. O. Bueno Calligaris",
50
N_("_Offset Palette..."),
53
(PF_PALETTE, "palette", _("Palette"), ""),
54
(PF_INT, "amount", _("Off_set"), 1),
56
[(PF_PALETTE, "new-palette", "Result")],
59
domain=("gimp20-python", gimp.locale_directory)