summaryrefslogtreecommitdiffstats
path: root/share/extensions/color_hsl_adjust.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /share/extensions/color_hsl_adjust.py
parentInitial commit. (diff)
downloadinkscape-12fc8abae6d434cac7670a59ed3a67301cc2eb10.tar.xz
inkscape-12fc8abae6d434cac7670a59ed3a67301cc2eb10.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'share/extensions/color_hsl_adjust.py')
-rwxr-xr-xshare/extensions/color_hsl_adjust.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/share/extensions/color_hsl_adjust.py b/share/extensions/color_hsl_adjust.py
new file mode 100755
index 0000000..cbe47e6
--- /dev/null
+++ b/share/extensions/color_hsl_adjust.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+"""Adjust all the HSL values"""
+
+import random
+import inkex
+
+
+class HslAdjust(inkex.ColorExtension):
+ """Modify the HSL levels of each color"""
+
+ def add_arguments(self, pars):
+ pars.add_argument("--tab")
+ pars.add_argument("-x", "--hue", type=int, default=0, help="Adjust hue")
+ pars.add_argument(
+ "-s", "--saturation", type=int, default=0, help="Adjust saturation"
+ )
+ pars.add_argument(
+ "-l", "--lightness", type=int, default=0, help="Adjust lightness"
+ )
+ pars.add_argument("--random_h", type=inkex.Boolean, dest="random_hue")
+ pars.add_argument("--random_s", type=inkex.Boolean, dest="random_saturation")
+ pars.add_argument("--random_l", type=inkex.Boolean, dest="random_lightness")
+
+ def modify_color(self, name, color):
+ if self.options.random_hue:
+ color.hue = int(random.random() * 255.0)
+ elif self.options.hue:
+ color.hue += self.options.hue * 256.0 / 360
+
+ if self.options.random_saturation:
+ color.saturation = int(random.random() * 255.0)
+ elif self.options.saturation:
+ color.saturation += self.options.saturation * 2.55
+
+ if self.options.random_lightness:
+ color.lightness = int(random.random() * 255.0)
+ elif self.options.lightness:
+ color.lightness += self.options.lightness * 2.55
+
+ return color
+
+
+if __name__ == "__main__":
+ HslAdjust().run()