diff options
| author | Alvin Penner <penner@vaxxine.com> | 2010-09-26 21:38:46 +0000 |
|---|---|---|
| committer | Alvin Penner <penner@vaxxine.com> | 2010-09-26 21:38:46 +0000 |
| commit | 5c688284693c1413796ff0f78cf79e472e8f7bf1 (patch) | |
| tree | 9ed8abd19ee9a021ac44ee236216c370fac212ea /share/extensions | |
| parent | Fix for Bug #586955 (the unit for user defined document size is not refreshed... (diff) | |
| download | inkscape-5c688284693c1413796ff0f78cf79e472e8f7bf1.tar.gz inkscape-5c688284693c1413796ff0f78cf79e472e8f7bf1.zip | |
option to choose (r,g,b) color scale (Bug 186432)
Fixed bugs:
- https://launchpad.net/bugs/186432
(bzr r9794)
Diffstat (limited to 'share/extensions')
| -rw-r--r-- | share/extensions/color_custom.inx | 22 | ||||
| -rw-r--r-- | share/extensions/color_custom.py | 25 |
2 files changed, 28 insertions, 19 deletions
diff --git a/share/extensions/color_custom.inx b/share/extensions/color_custom.inx index bb37f62ff..9cecbab1a 100644 --- a/share/extensions/color_custom.inx +++ b/share/extensions/color_custom.inx @@ -6,21 +6,25 @@ <dependency type="executable" location="extensions">color_custom.py</dependency> <dependency type="executable" location="extensions">simplestyle.py</dependency> <param name="tab" type="notebook"> - <page name="Options" _gui-text="Options"> - <param name="r" type="string" _gui-text="Red Function:" _gui-description="Function applied to the red channel">r</param> - <param name="g" type="string" _gui-text="Green Function:" _gui-description="Function applied to the green channel">g</param> - <param name="b" type="string" _gui-text="Blue Function:" _gui-description="Function applied to the blue channel">b</param> - </page> - <page name="Help" _gui-text="Help"> - <_param name="instructions" type="description" xml:space="preserve">Allows you to evaluate different functions for each channel. + <page name="Options" _gui-text="Options"> + <param name="r" type="string" _gui-text="Red Function:">r</param> + <param name="g" type="string" _gui-text="Green Function:">g</param> + <param name="b" type="string" _gui-text="Blue Function:">b</param> + <param name="scale" type="optiongroup" _gui-text="Input (r,g,b) Color Range"> + <option value="1">0 - 1</option> + <option value="255">0 - 255</option> + </param> + </page> + <page name="Help" _gui-text="Help"> + <_param name="instructions" type="description" xml:space="preserve">Allows you to evaluate different functions for each channel. r, g and b are the normalized values of the red, green and blue channels. The resulting RGB values are automatically clamped. Example (half the red, swap green and blue): Red Function: r*0.5 Green Function: b Blue Function: g</_param> - </page> - </param> + </page> + </param> <effect> <object-type>all</object-type> <effects-menu> diff --git a/share/extensions/color_custom.py b/share/extensions/color_custom.py index a90102d0f..3eefc3f55 100644 --- a/share/extensions/color_custom.py +++ b/share/extensions/color_custom.py @@ -20,22 +20,27 @@ class C(coloreffect.ColorEffect): action="store", type="string", dest="tab", help="The selected UI-tab when OK was pressed") + self.OptionParser.add_option("--scale", + action="store", type="string", + dest="scale", + help="The input (r,g,b) range") def normalize(self, v): if v<0: return 0.0 - if v>1: - return 1.0 + if v > float(self.options.scale): + return float(self.options.scale) return v def _hexstr(self,r,g,b): - return '%02x%02x%02x' % (int(round(r*255)),int(round(g*255)),int(round(b*255))) - + return '%02x%02x%02x' % (int(round(r)),int(round(g)),int(round(b))) + def colmod(self,_r,_g,_b): - r=float(_r)/255 - g=float(_g)/255 - b=float(_b)/255 - + factor = 255.0/float(self.options.scale) + r=float(_r)/factor + g=float(_g)/factor + b=float(_b)/factor + # add stuff to be accessible from within the custom color function here. safeenv = {'__builtins__':{},'r':r,'g':g,'b':b} @@ -44,8 +49,8 @@ class C(coloreffect.ColorEffect): g2=self.normalize(eval(self.options.gFunction,safeenv)) b2=self.normalize(eval(self.options.bFunction,safeenv)) except: - return self._hexstr(1.0,0.0,0.0) - return self._hexstr(r2,g2,b2) + return self._hexstr(255.0,0.0,0.0) + return self._hexstr(r2*factor,g2*factor,b2*factor) c = C() c.affect() |
