aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2023-02-24 23:28:28 -0800
committerGravatar Tom Willemse2023-02-24 23:28:28 -0800
commitb5b09921e3db981b221183c782f43dd27a87138a (patch)
tree41ba8024cd35858ecd6402f1fbdaded779ccde64
parentd1ca3d7874272eabddfd2b04331399af9459e073 (diff)
downloademacs-config-b5b09921e3db981b221183c782f43dd27a87138a.tar.gz
emacs-config-b5b09921e3db981b221183c782f43dd27a87138a.zip
feat(oni-org): Use the LCh color space to generate colors
Automatically generated colors for todo keywords and tags using an MD5 hash will produce a completely random color, frequently not fitting well at all within my chosen color theme. Using the LCh color space and keeping the L(uminance) and C(hroma) constant will produce colors that fit together much metter, and the values have been picked to work well with ‘yoshi-theme’. This change was inspired by “Arbitrary Beautiful Colors”[1]. [1]: https://khanlou.com/2023/02/arbitrary-beautiful-colors/
-rw-r--r--oni-org/oni-org.el9
1 files changed, 6 insertions, 3 deletions
diff --git a/oni-org/oni-org.el b/oni-org/oni-org.el
index 5a65b26..1416060 100644
--- a/oni-org/oni-org.el
+++ b/oni-org/oni-org.el
@@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2023.0108.154251
+;; Version: 2023.0224.232539
;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-contrib org-bullets org-edna diminish all-the-icons olivetti form-feed)
;; This program is free software; you can redistribute it and/or modify
@@ -35,6 +35,7 @@
;;; Code:
+(require 'color)
(require 'diminish)
(require 'hydra)
(require 'ob)
@@ -251,8 +252,10 @@ located at the start of the line."
(find-file (oni-org-expand-to-home "documents/gtd/index.org")))
(defun oni-org-color-for (object)
- "Generate a hex color by taking the first 6 characters of OBJECT’s MD5 sum."
- (format "#%s" (substring (md5 object) 0 6)))
+ "Generate a color for OBJECT by using its hash as a parameter for an LCh color."
+ (apply #'color-rgb-to-hex
+ (apply #'color-lab-to-srgb
+ (color-lch-to-lab 65 30 (mod (sxhash-equal object) 360)))))
(defun oni-org-generate-todo-keyword-faces ()
"Create faces for all todo keywords in the current buffer."