branch: externals/doric-themes commit 93e4222e8f8309786c1fc542b2f7eafbcc67ddf0 Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Introduce doric-themes-adjust-value to adjust a colour by a given percentage --- doric-themes.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doric-themes.el b/doric-themes.el index f1a4ca6567..196eba8105 100644 --- a/doric-themes.el +++ b/doric-themes.el @@ -36,6 +36,7 @@ ;;; Code: (require 'seq) +(require 'color) (eval-when-compile (require 'subr-x)) (defconst doric-themes-light-themes @@ -1308,6 +1309,14 @@ Run `doric-themes-after-load-theme-hook' after loading a theme." (backquote (list ',face (list (list t ,@attributes))))) faces))) +(defun doric-themes-adjust-value (hex-rgb percentage) + "Adjust value of HEX-RGB colour by PERCENTAGE." + (pcase-let* ((`(,r ,g ,b) (color-name-to-rgb hex-rgb)) + (fn (if (color-dark-p (list r g b)) + #'color-lighten-name + #'color-darken-name))) + (funcall fn hex-rgb percentage))) + ;;;###autoload (defmacro doric-themes-define-theme (name background-mode &optional description) "Define theme with NAME and `light' or `dark' BACKGROUND-MODE.