From b5b09921e3db981b221183c782f43dd27a87138a Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Fri, 24 Feb 2023 23:28:28 -0800 Subject: 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/ --- oni-org/oni-org.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'oni-org') 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 ;; 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." -- cgit v1.2.3-54-g00ecf