QLOOKアクセス解析

スポンサーサイト

上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。

スポンサー広告  |  ↑Top

2012/11/14 (Wed) 08:30

Inkscape Extension Hue Saturation Lightness

Free vector graphic editor Inkscape has color extensions to change hue, saturation and lightness by default. They are "More Hue", "Less Hue", "More Saturation", "Less Saturation", "More Light" and "Less Light". They can be called from "Menu" -> "Extensions" -> "Color".

However, they are not convenient. So I integrated these extensions to one. This new extension is free to use.

How to install
Create two files "color_huesaturationlightness.inx" and "color_huesaturationlightness.py" under ~/.config/inkscape/extensions/ or /usr/share/inkscape/extensions/ directory. Contents of these files are as bellow.

color_huesaturationlightness.inx

<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension>
    <_name>Hue Saturation Lightness</_name>
    <id>org.inkscape.color.huesaturationlightness</id>
    <dependency location="extensions" type="executable">coloreffect.py</dependency>
    <dependency location="extensions" type="executable">color_huesaturationlightness.py</dependency>
    <dependency location="extensions" type="executable">simplestyle.py</dependency>
    <param _gui-text="Hue (-180 - 180):  " max="180" min="-180" type="int" name="hue" />0
    <param _gui-text="Saturation (-128 - 128):  " max="128" min="-128" type="int" name="saturation" />0
    <param _gui-text="Lightness (-128 - 128):  " max="128" min="-128" type="int" name="lightness" />0
    <effect>
        <object-type>all</object-type>
        <effects-menu>
            <submenu _name="Color"></submenu>
        </effects-menu>
    </effect>
    <script>
        <command reldir="extensions" interpreter="python">color_huesaturationlightness.py</command>
    </script>
</inkscape-extension>


color_huesaturationlightness.py

#!/usr/bin/env python

import coloreffect, inkex

class C(coloreffect.ColorEffect):
  def __init__(self):
    coloreffect.ColorEffect.__init__(self)
    self.OptionParser.add_option("-H", "--hue",
                    action="store", type="int",
                    dest="hue", default=0,
                    help="hue (range -180 - 180)")
    self.OptionParser.add_option("-S", "--saturation",
                    action="store", type="int",
                    dest="saturation", default=0,
                    help="saturation (range -128 - 128)")
    self.OptionParser.add_option("-L", "--lightness",
                    action="store", type="int",
                    dest="lightness", default=0,
                    help="lightness (range -128 - 128)")

  def colmod(self,r,g,b):
    hsl = self.rgb_to_hsl(r/255.0, g/255.0, b/255.0)
    #inkex.debug("hsl: " + str(hsl[0]) + ", " + str(hsl[1]) + ", " + str(hsl[2]))

    # hue
    hsl[0] = hsl[0] + float(self.options.hue) / (180 * 2)
    if hsl[0] > 1.0:
        hsl[0] = hsl[0] - 1.0
    if hsl[0] < 0.0:
        hsl[0] = 1.0 + hsl[0]

    # saturation
    hsl[1] = hsl[1] + float(self.options.saturation) / (128 * 2)
    if hsl[1] > 1.0:
        hsl[1] = 1.0
    if hsl[1] < 0.0:
        hsl[1] = 0.0

    # lightness
    hsl[2] = hsl[2] + float(self.options.lightness) / 128
    if hsl[2] > 1.0:
        hsl[2] = 1.0
    if hsl[2] < 0.0:
        hsl[2] = 0.0

    #inkex.debug("hsl: " + str(hsl[0]) + ", " + str(hsl[1]) + ", " + str(hsl[2]))
    #inkex.debug("")
    rgb = self.hsl_to_rgb(hsl[0], hsl[1], hsl[2])
    return '%02x%02x%02x' % (rgb[0]*255, rgb[1]*255, rgb[2]*255)

if __name__ == '__main__':
    c = C()
    c.affect()


How to use
1) Select objects to change color.
2) Select "Menu" -> "Extensions" -> "Color" -> "Hue Saturation Lightness...".
3) Then a pop up window comes up. Change values as you like.
    HueSaturationLightness.png

This software is FREE, but ABSOLUTELY NO WARRANTY.
If any bugs, please add a comment. Fixing bug is most welcome.
スポンサーサイト

コンピュータ  |  トラックバック(1)  |  コメント(1)  |  ↑Top
 | HOME | 
上記広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書くことで広告を消せます。