diff options
author | Josh Rahm <rahm@google.com> | 2021-09-28 11:11:35 -0600 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2021-09-28 11:11:35 -0600 |
commit | 2ccaf8efc08d4609056fc6fb7a29740d4cfa93e6 (patch) | |
tree | 2407655aca9c855a6afe7b26f90028d2cef6ea22 /autoload/spectral.py | |
parent | e9258b72e94a2e9968989413d8ec77e74ceb291e (diff) | |
download | spectral.vim-2ccaf8efc08d4609056fc6fb7a29740d4cfa93e6.tar.gz spectral.vim-2ccaf8efc08d4609056fc6fb7a29740d4cfa93e6.tar.bz2 spectral.vim-2ccaf8efc08d4609056fc6fb7a29740d4cfa93e6.zip |
Add ability to set the saturation of a color.
Diffstat (limited to 'autoload/spectral.py')
-rw-r--r-- | autoload/spectral.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/autoload/spectral.py b/autoload/spectral.py index f7903aa..9afcf6b 100644 --- a/autoload/spectral.py +++ b/autoload/spectral.py @@ -3,7 +3,7 @@ import os import vim import colormath import colormath.color_diff -from colormath.color_objects import LabColor, sRGBColor +from colormath.color_objects import LabColor, sRGBColor, HSVColor from colormath.color_conversions import convert_color import sys import math @@ -423,6 +423,23 @@ def spectral_start(outfile): spectral_ctx = Vivid(outfile) spectral_ctx.start() +def set_saturation(color, amnt): + if isinstance(color, str): + color = sRGBColor.new_from_rgb_hex(color) + + print("Color " + str(color) + " " + get_rgb_hex(color)) + color_hsv = convert_color(color, HSVColor) + (h, s, v) = color_hsv.get_value_tuple() + + print("HSVPre " + str(color_hsv)) + color_hsv = HSVColor(h, amnt, v) + print("HSVPost " + str(color_hsv)) + return convert_color(color_hsv, sRGBColor) + +def spectral_set_saturation(color, amnt): + c = set_saturation(color, amnt) + vim.command('let g:return="%s"' % get_rgb_hex(c)) + def lighter(color, amt): if isinstance(color, str): |