diff options
| author | Nicolas Dufour <nicoduf@yahoo.fr> | 2012-09-13 19:37:54 +0000 |
|---|---|---|
| committer | JazzyNico <nicoduf@yahoo.fr> | 2012-09-13 19:37:54 +0000 |
| commit | 196475c81320f2ecd731714dcfb3a29191167d1a (patch) | |
| tree | 931c01944db4b7cb21a8269086b8844294b60bfc /share/extensions | |
| parent | Fix for 1048958 : Unexpected count '#' of swatch fill uses for clones (diff) | |
| download | inkscape-196475c81320f2ecd731714dcfb3a29191167d1a.tar.gz inkscape-196475c81320f2ecd731714dcfb3a29191167d1a.zip | |
Extensions. New HSL adjust extension (see Bug #979208 ).
(bzr r11665)
Diffstat (limited to 'share/extensions')
| -rw-r--r-- | share/extensions/Makefile.am | 4 | ||||
| -rw-r--r-- | share/extensions/color_HSL_adjust.inx | 36 | ||||
| -rw-r--r-- | share/extensions/color_HSL_adjust.py | 69 |
3 files changed, 108 insertions, 1 deletions
diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am index 74d8d2fd8..16c8a2cc2 100644 --- a/share/extensions/Makefile.am +++ b/share/extensions/Makefile.am @@ -26,6 +26,7 @@ extensions = \ color_desaturate.py\ coloreffect.py\ color_grayscale.py\ + color_HSL_adjust.py\ color_lesshue.py\ color_lesslight.py\ color_lesssaturation.py\ @@ -204,6 +205,7 @@ modules = \ color_darker.inx\ color_desaturate.inx\ color_grayscale.inx\ + color_HSL_adjust.inx\ color_lesshue.inx\ color_lesslight.inx\ color_lesssaturation.inx\ @@ -228,7 +230,7 @@ modules = \ dxf_output.inx \ edge3d.inx \ embedimage.inx \ - embedselectedimages.inx \ + embedselectedimages.inx \ eps_input.inx \ eqtexsvg.inx \ export_gimp_palette.inx \ diff --git a/share/extensions/color_HSL_adjust.inx b/share/extensions/color_HSL_adjust.inx new file mode 100644 index 000000000..4c0330f53 --- /dev/null +++ b/share/extensions/color_HSL_adjust.inx @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> + <_name>HSL Adjust</_name> + <id>org.inkscape.color.HSL_adjust</id> + <dependency type="executable" location="extensions">coloreffect.py</dependency> + <dependency type="executable" location="extensions">color_HSL_adjust.py</dependency> + <dependency type="executable" location="extensions">simplestyle.py</dependency> + <param name="tab" type="notebook"> + <page name="Options" _gui-text="Options"> + <param name="hue" type="int" appearance="full" min="-360" max="360" indent="0" _gui-text="Hue (°):">0</param> + <param name="random_h" type="boolean" _gui-text="Ramdom hue">false</param> + <param name="saturation" type="int" appearance="full" min="-100" max="100" indent="0" _gui-text="Saturation (%):">0</param> + <param name="random_s" type="boolean" _gui-text="Ramdom saturation">false</param> + <param name="lightness" type="int" appearance="full" min="-100" max="100" indent="0" _gui-text="Lightness (%):">0</param> + <param name="random_l" type="boolean" _gui-text="Ramdom lightness">false</param> + </page> + <page name="Help" _gui-text="Help"> + <_param name="instructions" type="description" xml:space="preserve">Adjusts hue, saturation and lightness in the HSL representation of the selected objects's color. +Options: + * Hue: rotate by degrees (wraps around). + * Saturation: add/subtract % (min=-100, max=100). + * Lightness: add/subtract % (min=-100, max=100). + * Random Hue/Saturation/Lightness: randomize the parameter's value. + </_param> + </page> + </param> + <effect> + <object-type>all</object-type> + <effects-menu> + <submenu _name="Color"/> + </effects-menu> + </effect> + <script> + <command reldir="extensions" interpreter="python">color_HSL_adjust.py</command> + </script> +</inkscape-extension> diff --git a/share/extensions/color_HSL_adjust.py b/share/extensions/color_HSL_adjust.py new file mode 100644 index 000000000..473c4bd1e --- /dev/null +++ b/share/extensions/color_HSL_adjust.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python + +# standard library +import random +# local library +import coloreffect +import inkex + +class C(coloreffect.ColorEffect): + def __init__(self): + coloreffect.ColorEffect.__init__(self) + self.OptionParser.add_option("-x", "--hue", + action="store", type="int", + dest="hue", default="0", + help="Adjust hue") + self.OptionParser.add_option("-s", "--saturation", + action="store", type="int", + dest="saturation", default="0", + help="Adjust saturation") + self.OptionParser.add_option("-l", "--lightness", + action="store", type="int", + dest="lightness", default="0", + help="Adjust lightness") + self.OptionParser.add_option("", "--random_h", + action="store", type="inkbool", + dest="random_hue", default=False, + help="Randomize hue") + self.OptionParser.add_option("", "--random_s", + action="store", type="inkbool", + dest="random_saturation", default=False, + help="Randomize saturation") + self.OptionParser.add_option("", "--random_l", + action="store", type="inkbool", + dest="random_lightness", default=False, + help="Randomize lightness") + self.OptionParser.add_option("--tab", + action="store", type="string", + dest="tab", + help="The selected UI-tab when OK was pressed") + + def clamp(self, minimum, x, maximum): + return max(minimum, min(x, maximum)) + + def colmod(self, r, g, b): + hsl = self.rgb_to_hsl(r/255.0, g/255.0, b/255.0) + #inkex.debug("hsl old: " + str(hsl[0]) + ", " + str(hsl[1]) + ", " + str(hsl[2])) + if (self.options.random_hue): + hsl[0] = random.random() + elif (self.options.hue): + hueval = hsl[0] + (self.options.hue / 360.0) + hsl[0] = hueval % 1 + if(self.options.random_saturation): + hsl[1] = random.random() + elif (self.options.saturation): + satval = hsl[1] + (self.options.saturation / 100.0) + hsl[1] = self.clamp(0.0, satval, 1.0) + if(self.options.random_lightness): + hsl[2] = random.random() + elif (self.options.lightness): + lightval = hsl[2] + (self.options.lightness / 100.0) + hsl[2] = self.clamp(0.0, lightval, 1.0) + #inkex.debug("hsl new: " + str(hsl[0]) + ", " + str(hsl[1]) + ", " + str(hsl[2])) + rgb = self.hsl_to_rgb(hsl[0], hsl[1], hsl[2]) + return '%02x%02x%02x' % (rgb[0]*255, rgb[1]*255, rgb[2]*255) + +c = C() +c.affect() + +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 |
