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/
This commit is contained in:
parent
d1ca3d7874
commit
b5b09921e3
1 changed files with 6 additions and 3 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
;; Author: Tom Willemse <tom@ryuslash.org>
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
||||||
;; Keywords: local
|
;; 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)
|
;; 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
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
(require 'color)
|
||||||
(require 'diminish)
|
(require 'diminish)
|
||||||
(require 'hydra)
|
(require 'hydra)
|
||||||
(require 'ob)
|
(require 'ob)
|
||||||
|
@ -251,8 +252,10 @@ located at the start of the line."
|
||||||
(find-file (oni-org-expand-to-home "documents/gtd/index.org")))
|
(find-file (oni-org-expand-to-home "documents/gtd/index.org")))
|
||||||
|
|
||||||
(defun oni-org-color-for (object)
|
(defun oni-org-color-for (object)
|
||||||
"Generate a hex color by taking the first 6 characters of OBJECT’s MD5 sum."
|
"Generate a color for OBJECT by using its hash as a parameter for an LCh color."
|
||||||
(format "#%s" (substring (md5 object) 0 6)))
|
(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 ()
|
(defun oni-org-generate-todo-keyword-faces ()
|
||||||
"Create faces for all todo keywords in the current buffer."
|
"Create faces for all todo keywords in the current buffer."
|
||||||
|
|
Loading…
Reference in a new issue