Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neeasade/ct.el
color tools for emacs
https://github.com/neeasade/ct.el
colors emacs hsl lab lch
Last synced: 3 days ago
JSON representation
color tools for emacs
- Host: GitHub
- URL: https://github.com/neeasade/ct.el
- Owner: neeasade
- License: mit
- Created: 2020-12-29T17:34:00.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2025-02-05T12:58:17.000Z (15 days ago)
- Last Synced: 2025-02-05T13:24:13.378Z (15 days ago)
- Topics: colors, emacs, hsl, lab, lch
- Language: Emacs Lisp
- Homepage:
- Size: 285 KB
- Stars: 94
- Watchers: 3
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: readme.org
- Changelog: changelog.org
- License: LICENSE
Awesome Lists containing this project
README
# NOTE: this file is generated, see the docs branch to make edits
# NOTE: this file is generated, see the docs branch to make edits
# NOTE: this file is generated, see the docs branch to make edits
# NOTE: this file is generated, see the docs branch to make edits
# NOTE: this file is generated, see the docs branch to make edits
# NOTE: this file is generated, see the docs branch to make edits
# NOTE: this file is generated, see the docs branch to make edits
# NOTE: this file is generated, see the docs branch to make edits
# NOTE: this file is generated, see the docs branch to make edits[[https://raw.githubusercontent.com/neeasade/ct.el/refs/heads/docs/example.png]]
#+html:
🔵 🟣 🟢 🟤 🟡 🔴 ðŸŸ
#+html:ct.el (color tools) is a color library for Emacs meant for making changes to individual colors in various color spaces. Builds on top of [[https://github.com/emacs-mirror/emacs/blob/master/lisp/color.el][color.el]] and [[https://github.com/hsluv/hsluv-emacs][hsluv-emacs]], providing a consistent interface to many color spaces, in addition to some utility functions. Visualized in [[https://notes.neeasade.net/color-spaces.html][this blog post]], used to create [[https://github.com/neeasade/myron-themes][myron-themes]]. Shouted out by [[https://protesilaos.com/codelog/2021-01-11-modus-themes-review-select-faint-colours/][prot]] (of modus themes fame).
Supported color spaces: [[#rgb][rgb]] • [[#hsl][hsl]] • [[#hsv][hsv]] • [[#hsluv][hsluv]] • [[#hpluv][hpluv]] • [[#cielab][(cie)lab]] • [[#cielch][(cie)lch]] • [[#okLAB][(ok)lab]]
** Installationct.el is on [[https://melpa.org/#/ct][melpa]]. You may also install with [[https://github.com/raxod502/straight.el][straight.el]]:
#+begin_src emacs-lisp
(straight-use-package '(ct :host github :repo "neeasade/ct.el" :branch "master"))
#+end_src** Conventions
- Colorspace number range values are 0-100
- Exception: Hue (0-360 degrees)
- Exception: L(*AB*) (-100-100)
- Values are clamped to valid ranges coming out of the ~ct-edit-*~ functions** Functions
*** Color Properties
- [[#ct-contrast-ratio-color1-color2][ct-contrast-ratio]] ~(color1 color2)~
- [[#ct-distance-color1-color2][ct-distance]] ~(color1 color2)~
- [[#ct-light-p-color-optional-threshold][ct-light-p]] ~(color &optional threshold)~
- [[#ct-format-argb-color-optional-opacity-end][ct-format-argb]] ~(color &optional opacity end)~
- [[#ct-format-rbga-color-optional-opacity][ct-format-rbga]] ~(color &optional opacity)~
*** Color Modification
- [[#ct-complement-color][ct-complement]] ~(color)~
- [[#ct-gradient-step-start-end-optional-with-ends-space][ct-gradient]] ~(step start end &optional with-ends space)~
- [[#ct-greaten-color-optional-percent][ct-greaten]] ~(color &optional percent)~
- [[#ct-lessen-color-optional-percent][ct-lessen]] ~(color &optional percent)~
- [[#ct-iterate-color-edit-fn-condition][ct-iterate]] ~(color edit-fn condition)~
- [[#ct-iterations-color-edit-fn-condition][ct-iterations]] ~(color edit-fn condition)~
- [[#ct-lab-change-whitepoint-color-white-point-white-point-new][ct-lab-change-whitepoint]] ~(color white-point white-point-new)~
- [[#ct-mix-colors-optional-colorspace][ct-mix]] ~(colors &optional colorspace)~
- [[#ct-mix-opacity-top-bottom-opacity][ct-mix-opacity]] ~(top bottom opacity)~
- [[#ct-pastel-color-optional-smod-vmod][ct-pastel]] ~(color &optional smod vmod)~
- [[#ct-contrast-min-foreground-background-contrast-ratio-optional-color-property][ct-contrast-min]] ~(foreground background contrast-ratio &optional color-property)~
- [[#ct-contrast-max-foreground-background-contrast-ratio-optional-color-property][ct-contrast-max]] ~(foreground background contrast-ratio &optional color-property)~
- [[#ct-steal-color-property-color2][ct-steal]] ~(color property color2)~
- [[#ct-rotation-hsl-count-color][ct-rotation-hsl]] ~(count color)~
- [[#ct-rotation-hsluv-count-color][ct-rotation-hsluv]] ~(count color)~
- [[#ct-rotation-hpluv-count-color][ct-rotation-hpluv]] ~(count color)~
- [[#ct-rotation-hsv-count-color][ct-rotation-hsv]] ~(count color)~
- [[#ct-rotation-lch-count-color][ct-rotation-lch]] ~(count color)~
*** RGB
- [[#ct-make-rgb-red-green-blue][ct-make-rgb]] ~(red green blue)~
- [[#ct-get-rgb-color][ct-get-rgb]] ~(color)~
- [[#ct-get-rgb-r-color][ct-get-rgb-r]] ~(color)~
- [[#ct-get-rgb-g-color][ct-get-rgb-g]] ~(color)~
- [[#ct-get-rgb-b-color][ct-get-rgb-b]] ~(color)~
- [[#ct-edit-rgb-color-edit-fn][ct-edit-rgb]] ~(color edit-fn)~
- [[#ct-edit-rgb-b-color-func-or-val][ct-edit-rgb-b]] ~(color func-or-val)~
- [[#ct-edit-rgb-b-dec-color-optional-amount][ct-edit-rgb-b-dec]] ~(color &optional amount)~
- [[#ct-edit-rgb-b-inc-color-optional-amount][ct-edit-rgb-b-inc]] ~(color &optional amount)~
- [[#ct-edit-rgb-g-color-func-or-val][ct-edit-rgb-g]] ~(color func-or-val)~
- [[#ct-edit-rgb-g-dec-color-optional-amount][ct-edit-rgb-g-dec]] ~(color &optional amount)~
- [[#ct-edit-rgb-g-inc-color-optional-amount][ct-edit-rgb-g-inc]] ~(color &optional amount)~
- [[#ct-edit-rgb-r-color-func-or-val][ct-edit-rgb-r]] ~(color func-or-val)~
- [[#ct-edit-rgb-r-dec-color-optional-amount][ct-edit-rgb-r-dec]] ~(color &optional amount)~
- [[#ct-edit-rgb-r-inc-color-optional-amount][ct-edit-rgb-r-inc]] ~(color &optional amount)~
*** (cie)LAB
- [[#ct-make-lab-lightness-a-b][ct-make-lab]] ~(lightness a b)~
- [[#ct-get-lab-color][ct-get-lab]] ~(color)~
- [[#ct-get-lab-l-color][ct-get-lab-l]] ~(color)~
- [[#ct-get-lab-b-color][ct-get-lab-b]] ~(color)~
- [[#ct-get-lab-a-color][ct-get-lab-a]] ~(color)~
- [[#ct-edit-lab-color-edit-fn][ct-edit-lab]] ~(color edit-fn)~
- [[#ct-edit-lab-a-color-func-or-val][ct-edit-lab-a]] ~(color func-or-val)~
- [[#ct-edit-lab-a-dec-color-optional-amount][ct-edit-lab-a-dec]] ~(color &optional amount)~
- [[#ct-edit-lab-a-inc-color-optional-amount][ct-edit-lab-a-inc]] ~(color &optional amount)~
- [[#ct-edit-lab-b-color-func-or-val][ct-edit-lab-b]] ~(color func-or-val)~
- [[#ct-edit-lab-b-dec-color-optional-amount][ct-edit-lab-b-dec]] ~(color &optional amount)~
- [[#ct-edit-lab-b-inc-color-optional-amount][ct-edit-lab-b-inc]] ~(color &optional amount)~
- [[#ct-edit-lab-l-color-func-or-val][ct-edit-lab-l]] ~(color func-or-val)~
- [[#ct-edit-lab-l-dec-color-optional-amount][ct-edit-lab-l-dec]] ~(color &optional amount)~
- [[#ct-edit-lab-l-inc-color-optional-amount][ct-edit-lab-l-inc]] ~(color &optional amount)~
*** HSL
- [[#ct-make-hsl-hue-saturation-lightness][ct-make-hsl]] ~(hue saturation lightness)~
- [[#ct-get-hsl-color][ct-get-hsl]] ~(color)~
- [[#ct-get-hsl-s-color][ct-get-hsl-s]] ~(color)~
- [[#ct-get-hsl-l-color][ct-get-hsl-l]] ~(color)~
- [[#ct-get-hsl-h-color][ct-get-hsl-h]] ~(color)~
- [[#ct-edit-hsl-color-edit-fn][ct-edit-hsl]] ~(color edit-fn)~
- [[#ct-edit-hsl-h-color-func-or-val][ct-edit-hsl-h]] ~(color func-or-val)~
- [[#ct-edit-hsl-h-dec-color-optional-amount][ct-edit-hsl-h-dec]] ~(color &optional amount)~
- [[#ct-edit-hsl-h-inc-color-optional-amount][ct-edit-hsl-h-inc]] ~(color &optional amount)~
- [[#ct-edit-hsl-l-color-func-or-val][ct-edit-hsl-l]] ~(color func-or-val)~
- [[#ct-edit-hsl-l-dec-color-optional-amount][ct-edit-hsl-l-dec]] ~(color &optional amount)~
- [[#ct-edit-hsl-l-inc-color-optional-amount][ct-edit-hsl-l-inc]] ~(color &optional amount)~
- [[#ct-edit-hsl-s-color-func-or-val][ct-edit-hsl-s]] ~(color func-or-val)~
- [[#ct-edit-hsl-s-dec-color-optional-amount][ct-edit-hsl-s-dec]] ~(color &optional amount)~
- [[#ct-edit-hsl-s-inc-color-optional-amount][ct-edit-hsl-s-inc]] ~(color &optional amount)~
*** HSLuv
- [[#ct-make-hsluv-hue-saturation-lightness][ct-make-hsluv]] ~(hue saturation lightness)~
- [[#ct-get-hsluv-color][ct-get-hsluv]] ~(color)~
- [[#ct-get-hsluv-s-color][ct-get-hsluv-s]] ~(color)~
- [[#ct-get-hsluv-l-color][ct-get-hsluv-l]] ~(color)~
- [[#ct-get-hsluv-h-color][ct-get-hsluv-h]] ~(color)~
- [[#ct-edit-hsluv-color-edit-fn][ct-edit-hsluv]] ~(color edit-fn)~
- [[#ct-edit-hsluv-h-color-func-or-val][ct-edit-hsluv-h]] ~(color func-or-val)~
- [[#ct-edit-hsluv-h-dec-color-optional-amount][ct-edit-hsluv-h-dec]] ~(color &optional amount)~
- [[#ct-edit-hsluv-h-inc-color-optional-amount][ct-edit-hsluv-h-inc]] ~(color &optional amount)~
- [[#ct-edit-hsluv-l-color-func-or-val][ct-edit-hsluv-l]] ~(color func-or-val)~
- [[#ct-edit-hsluv-l-dec-color-optional-amount][ct-edit-hsluv-l-dec]] ~(color &optional amount)~
- [[#ct-edit-hsluv-l-inc-color-optional-amount][ct-edit-hsluv-l-inc]] ~(color &optional amount)~
- [[#ct-edit-hsluv-s-color-func-or-val][ct-edit-hsluv-s]] ~(color func-or-val)~
- [[#ct-edit-hsluv-s-dec-color-optional-amount][ct-edit-hsluv-s-dec]] ~(color &optional amount)~
- [[#ct-edit-hsluv-s-inc-color-optional-amount][ct-edit-hsluv-s-inc]] ~(color &optional amount)~
*** (cie)LCH
- [[#ct-make-lch-lightness-chroma-hue][ct-make-lch]] ~(lightness chroma hue)~
- [[#ct-get-lch-color][ct-get-lch]] ~(color)~
- [[#ct-get-lch-l-color][ct-get-lch-l]] ~(color)~
- [[#ct-get-lch-h-color][ct-get-lch-h]] ~(color)~
- [[#ct-get-lch-c-color][ct-get-lch-c]] ~(color)~
- [[#ct-edit-lch-color-edit-fn][ct-edit-lch]] ~(color edit-fn)~
- [[#ct-edit-lch-c-color-func-or-val][ct-edit-lch-c]] ~(color func-or-val)~
- [[#ct-edit-lch-c-dec-color-optional-amount][ct-edit-lch-c-dec]] ~(color &optional amount)~
- [[#ct-edit-lch-c-inc-color-optional-amount][ct-edit-lch-c-inc]] ~(color &optional amount)~
- [[#ct-edit-lch-h-color-func-or-val][ct-edit-lch-h]] ~(color func-or-val)~
- [[#ct-edit-lch-h-dec-color-optional-amount][ct-edit-lch-h-dec]] ~(color &optional amount)~
- [[#ct-edit-lch-h-inc-color-optional-amount][ct-edit-lch-h-inc]] ~(color &optional amount)~
- [[#ct-edit-lch-l-color-func-or-val][ct-edit-lch-l]] ~(color func-or-val)~
- [[#ct-edit-lch-l-dec-color-optional-amount][ct-edit-lch-l-dec]] ~(color &optional amount)~
- [[#ct-edit-lch-l-inc-color-optional-amount][ct-edit-lch-l-inc]] ~(color &optional amount)~
*** HSV
- [[#ct-make-hsv-hue-saturation-value][ct-make-hsv]] ~(hue saturation value)~
- [[#ct-get-hsv-color][ct-get-hsv]] ~(color)~
- [[#ct-get-hsv-v-color][ct-get-hsv-v]] ~(color)~
- [[#ct-get-hsv-s-color][ct-get-hsv-s]] ~(color)~
- [[#ct-get-hsv-h-color][ct-get-hsv-h]] ~(color)~
- [[#ct-edit-hsv-color-edit-fn][ct-edit-hsv]] ~(color edit-fn)~
- [[#ct-edit-hsv-h-color-func-or-val][ct-edit-hsv-h]] ~(color func-or-val)~
- [[#ct-edit-hsv-h-dec-color-optional-amount][ct-edit-hsv-h-dec]] ~(color &optional amount)~
- [[#ct-edit-hsv-h-inc-color-optional-amount][ct-edit-hsv-h-inc]] ~(color &optional amount)~
- [[#ct-edit-hsv-s-color-func-or-val][ct-edit-hsv-s]] ~(color func-or-val)~
- [[#ct-edit-hsv-s-dec-color-optional-amount][ct-edit-hsv-s-dec]] ~(color &optional amount)~
- [[#ct-edit-hsv-s-inc-color-optional-amount][ct-edit-hsv-s-inc]] ~(color &optional amount)~
- [[#ct-edit-hsv-v-color-func-or-val][ct-edit-hsv-v]] ~(color func-or-val)~
- [[#ct-edit-hsv-v-dec-color-optional-amount][ct-edit-hsv-v-dec]] ~(color &optional amount)~
- [[#ct-edit-hsv-v-inc-color-optional-amount][ct-edit-hsv-v-inc]] ~(color &optional amount)~
*** HPLUV
- [[#ct-make-hpluv-hue-percentage-saturation-lightness][ct-make-hpluv]] ~(hue percentage-saturation lightness)~
- [[#ct-get-hpluv-color][ct-get-hpluv]] ~(color)~
- [[#ct-get-hpluv-p-color][ct-get-hpluv-p]] ~(color)~
- [[#ct-get-hpluv-l-color][ct-get-hpluv-l]] ~(color)~
- [[#ct-get-hpluv-h-color][ct-get-hpluv-h]] ~(color)~
- [[#ct-edit-hpluv-color-edit-fn][ct-edit-hpluv]] ~(color edit-fn)~
- [[#ct-edit-hpluv-h-color-func-or-val][ct-edit-hpluv-h]] ~(color func-or-val)~
- [[#ct-edit-hpluv-h-dec-color-optional-amount][ct-edit-hpluv-h-dec]] ~(color &optional amount)~
- [[#ct-edit-hpluv-h-inc-color-optional-amount][ct-edit-hpluv-h-inc]] ~(color &optional amount)~
- [[#ct-edit-hpluv-l-color-func-or-val][ct-edit-hpluv-l]] ~(color func-or-val)~
- [[#ct-edit-hpluv-l-dec-color-optional-amount][ct-edit-hpluv-l-dec]] ~(color &optional amount)~
- [[#ct-edit-hpluv-l-inc-color-optional-amount][ct-edit-hpluv-l-inc]] ~(color &optional amount)~
- [[#ct-edit-hpluv-p-color-func-or-val][ct-edit-hpluv-p]] ~(color func-or-val)~
- [[#ct-edit-hpluv-p-dec-color-optional-amount][ct-edit-hpluv-p-dec]] ~(color &optional amount)~
- [[#ct-edit-hpluv-p-inc-color-optional-amount][ct-edit-hpluv-p-inc]] ~(color &optional amount)~
*** okLAB
- [[#ct-make-oklab-lightness-a-b][ct-make-oklab]] ~(lightness a b)~
- [[#ct-get-oklab-color][ct-get-oklab]] ~(color)~
- [[#ct-get-oklab-l-color][ct-get-oklab-l]] ~(color)~
- [[#ct-get-oklab-a-color][ct-get-oklab-a]] ~(color)~
- [[#ct-get-oklab-b-color][ct-get-oklab-b]] ~(color)~
- [[#ct-edit-oklab-color-edit-fn][ct-edit-oklab]] ~(color edit-fn)~
- [[#ct-edit-oklab-l-color-func-or-val][ct-edit-oklab-l]] ~(color func-or-val)~
- [[#ct-edit-oklab-l-dec-color-optional-amount][ct-edit-oklab-l-dec]] ~(color &optional amount)~
- [[#ct-edit-oklab-l-inc-color-optional-amount][ct-edit-oklab-l-inc]] ~(color &optional amount)~
- [[#ct-edit-oklab-a-color-func-or-val][ct-edit-oklab-a]] ~(color func-or-val)~
- [[#ct-edit-oklab-a-dec-color-optional-amount][ct-edit-oklab-a-dec]] ~(color &optional amount)~
- [[#ct-edit-oklab-a-inc-color-optional-amount][ct-edit-oklab-a-inc]] ~(color &optional amount)~
- [[#ct-edit-oklab-b-color-func-or-val][ct-edit-oklab-b]] ~(color func-or-val)~
- [[#ct-edit-oklab-b-dec-color-optional-amount][ct-edit-oklab-b-dec]] ~(color &optional amount)~
- [[#ct-edit-oklab-b-inc-color-optional-amount][ct-edit-oklab-b-inc]] ~(color &optional amount)~
** Color Properties
Functions for seeing properties of colors not necessarily related to a particular color space.
**** ct-contrast-ratio ~(color1 color2)~
Get the contrast ratio between COLOR1 and COLOR2.
#+BEGIN_src elisp
(ct-contrast-ratio "#bbbbbb" "#4fa5e8") ;; => 1
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/bbbbbb.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 1
#+END_quote
**** ct-distance ~(color1 color2)~
Get cie-DE2000 distance between COLOR1 and COLOR2, range 0-100.
#+BEGIN_src elisp
(ct-distance "#4fa5e8" "#bc9a43") ;; => 53
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]],[[http://muffin.app.neeasade.net/colorsquare/bc9a43.svg]] → 53
#+END_quote
**** ct-light-p ~(color &optional threshold)~
Determine if a COLOR passes a cieLAB lightness THRESHOLD.
#+BEGIN_src elisp
(ct-light-p "#4fa5e8") ;; => t
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → t
#+END_quote
**** ct-format-argb ~(color &optional opacity end)~
Argb formatting:
Pass in COLOR and OPACITY 0-100, get a string representation of COLOR as
follows: '#AAFFFFFF', where AA is a hex pair for the alpha, followed by FF times
3 hex pairs for red, green, blue. If END is truthy, then format will be
'#FFFFFFAA'.
#+BEGIN_src elisp
(ct-format-argb "#4fa5e8" 80 t) ;; => "#4fa5e8cc"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → #4fa5e8cc
#+END_quote
**** ct-format-rbga ~(color &optional opacity)~
RGBA formatting:
Pass in COLOR and OPACITY 0-100, get a string
representation of COLOR as follows: 'rgba(R, G, B, OPACITY)', where
values RGB are 0-255, and OPACITY is 0-1.0 (default 1.0).
#+BEGIN_src elisp
(ct-format-rbga "#4fa5e8" 80) ;; => "rgba(79, 165, 232, 0.8)"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → rgba(79, 165, 232, 0.8)
#+END_quote
** Color Modification
Functions for modifying colors in some way potentially unrelated to a specific colorspace
**** ct-complement ~(color)~
Return a color complement of COLOR in the HSLUV space.
#+BEGIN_src elisp
(ct-complement "#4fa5e8") ;; => "#bc9a43"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/bc9a43.svg]]
#+END_quote
**** ct-gradient ~(step start end &optional with-ends space)~
Create a gradient from color START to color END in STEP parts.
Optionally include START and END in results using
WITH-ENDS. Optionally choose a colorspace with SPACE (see
'ct--colorspace-map'). Hue-inclusive colorspaces may see mixed
results.
#+BEGIN_src elisp
(ct-gradient 5 "#4fa5e8" "#bc9a43" t) ;; => ("#4fa5e8" "#6aa2be" "#859f95" "#a09c6c" "#bc9a43")
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]],[[http://muffin.app.neeasade.net/colorsquare/bc9a43.svg]] → [[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]],[[http://muffin.app.neeasade.net/colorsquare/6aa2be.svg]],[[http://muffin.app.neeasade.net/colorsquare/859f95.svg]],[[http://muffin.app.neeasade.net/colorsquare/a09c6c.svg]],[[http://muffin.app.neeasade.net/colorsquare/bc9a43.svg]]
#+END_quote
**** ct-greaten ~(color &optional percent)~
Make a light COLOR lighter, a dark COLOR darker (by PERCENT).
#+BEGIN_src elisp
(ct-greaten "#4fa5e8" 20) ;; => "#8ddbff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/8ddbff.svg]]
#+END_quote
**** ct-lessen ~(color &optional percent)~
Make a light COLOR darker, or a dark COLOR lighter (by PERCENT).
#+BEGIN_src elisp
(ct-lessen "#4fa5e8" 20) ;; => "#0071af"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/0071af.svg]]
#+END_quote
**** ct-iterate ~(color edit-fn condition)~
Change COLOR using EDIT-FN until CONDITION is met.
Will return early if calling EDIT-FN results in no change.
#+BEGIN_src elisp
(ct-iterate "#4fa5e8" 'ct-edit-hsv-v-inc (lambda (c) (> (ct-distance c "#4fa5e8") 10))) ;; => "#4f98ff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/4f98ff.svg]]
#+END_quote
**** ct-iterations ~(color edit-fn condition)~
Change COLOR using EDIT-FN until CONDITION is met, returning each step.
Will return early if calling EDIT-FN results in no change.
#+BEGIN_src elisp
(ct-iterations "#4fa5e8" 'ct-edit-hsv-v-inc (lambda (c) (> (ct-distance c "#4fa5e8") 10))) ;; => ("#4fa5e8" "#4fa5e9" "#4fa5ea" "#4fa5eb" "#4fa5ec" "#4fa5ed" "#4fa5ee" "#4fa5ef" "#4fa5f0" "#4fa5f1" "#4fa5f2" "#4fa5f3" "#4fa5f4" "#4fa5f5" "#4fa5f6" "#4fa5f7" "#4fa5f8" "#4fa5f9" "#4fa5fa" "#4fa5fb" "#4fa5fc" "#4fa5fd" "#4fa5fe" "#4fa5ff" "#4fa4ff" "#4fa3ff" "#4fa2ff" "#4fa1ff" "#4fa0ff" "#4f9fff" "#4f9eff" "#4f9dff" "#4f9cff" "#4f9bff" "#4f9aff" "#4f99ff" "#4f98ff")
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5e9.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5ea.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5eb.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5ec.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5ed.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5ee.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5ef.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5f0.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5f1.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5f2.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5f3.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5f4.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5f5.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5f6.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5f7.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5f8.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5f9.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5fa.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5fb.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5fc.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5fd.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5fe.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5ff.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa4ff.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa3ff.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa2ff.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa1ff.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa0ff.svg]],[[http://muffin.app.neeasade.net/colorsquare/4f9fff.svg]],[[http://muffin.app.neeasade.net/colorsquare/4f9eff.svg]],[[http://muffin.app.neeasade.net/colorsquare/4f9dff.svg]],[[http://muffin.app.neeasade.net/colorsquare/4f9cff.svg]],[[http://muffin.app.neeasade.net/colorsquare/4f9bff.svg]],[[http://muffin.app.neeasade.net/colorsquare/4f9aff.svg]],[[http://muffin.app.neeasade.net/colorsquare/4f99ff.svg]],[[http://muffin.app.neeasade.net/colorsquare/4f98ff.svg]]
#+END_quote
**** ct-lab-change-whitepoint ~(color white-point white-point-new)~
Transform COLOR by changing it's cieLAB WHITE-POINT property to WHITE-POINT-NEW.
#+BEGIN_src elisp
(ct-lab-change-whitepoint "#4fa5e8" color-d50-xyz color-d55-xyz) ;; => "#29a6f4"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/29a6f4.svg]]
#+END_quote
**** ct-mix ~(colors &optional colorspace)~
Mix COLORS in COLORSPACE. See also: 'ct--colorspace-map'.
#+BEGIN_src elisp
(ct-mix (list "#4fa5e8" "#bbbbbb" "#bc9a43")) ;; => "#a0a48a"
#+END_src
#+BEGIN_quote
→ [[http://muffin.app.neeasade.net/colorsquare/a0a48a.svg]]
#+END_quote
**** ct-mix-opacity ~(top bottom opacity)~
Get resulting color of TOP color with OPACITY overlayed against BOTTOM. Opacity is expected to be 0.0-1.0.
#+BEGIN_src elisp
(ct-mix-opacity "#4fa5e8" "#bbbbbb" 1) ;; => "#4fa4e8"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]],[[http://muffin.app.neeasade.net/colorsquare/bbbbbb.svg]] → [[http://muffin.app.neeasade.net/colorsquare/4fa4e8.svg]]
#+END_quote
**** ct-pastel ~(color &optional smod vmod)~
Make COLOR more 'pastel' using the hsluv space -- optionally change the rate of change with SMOD and VMOD.
#+BEGIN_src elisp
(ct-pastel "#4fa5e8") ;; => "#77a2c4"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/77a2c4.svg]]
#+END_quote
**** ct-contrast-min ~(foreground background contrast-ratio &optional color-property)~
Edit FOREGROUND to have a minimum CONTRAST-RATIO on BACKGROUND.Optionally specify the COLOR-PROPERTY used to tweak foreground (default 'lab-l)
#+BEGIN_src elisp
(ct-contrast-min "#4fa5e8" "#bbbbbb" 3) ;; => "#1369ac"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]],[[http://muffin.app.neeasade.net/colorsquare/bbbbbb.svg]] → [[http://muffin.app.neeasade.net/colorsquare/1369ac.svg]]
#+END_quote
**** ct-contrast-max ~(foreground background contrast-ratio &optional color-property)~
Edit FOREGROUND to have a maximum CONTRAST-RATIO on BACKGROUND.Optionally specify the COLOR-PROPERTY used to tweak foreground (default 'lab-l)
#+BEGIN_src elisp
(ct-contrast-max "#000000" "#dddddd" 4) ;; => "#6a6a6a"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/000000.svg]],[[http://muffin.app.neeasade.net/colorsquare/dddddd.svg]] → [[http://muffin.app.neeasade.net/colorsquare/6a6a6a.svg]]
#+END_quote
**** ct-steal ~(color property color2)~
Steal PROPERTY of COLOR2 and set it on COLOR.PROPERTY is a symbol of a colorspace property, such as 'hsluv-l
#+BEGIN_src elisp
(ct-steal "#bbbbbb" 'hsv-h "#4fa5e8") ;; => "#bbbbbb"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/bbbbbb.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/bbbbbb.svg]]
#+END_quote
**** ct-rotation-hsl ~(count color)~
Perform a hue rotation in hsl space starting with COLOR, generating COUNT colors.
#+BEGIN_src elisp
(ct-rotation-hsl 6 "#4fa5e8") ;; => ("#4fa4e8" "#914fe8" "#e84fa4" "#e8914f" "#a5e84f" "#4fe892")
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/4fa4e8.svg]],[[http://muffin.app.neeasade.net/colorsquare/914fe8.svg]],[[http://muffin.app.neeasade.net/colorsquare/e84fa4.svg]],[[http://muffin.app.neeasade.net/colorsquare/e8914f.svg]],[[http://muffin.app.neeasade.net/colorsquare/a5e84f.svg]],[[http://muffin.app.neeasade.net/colorsquare/4fe892.svg]]
#+END_quote
**** ct-rotation-hsluv ~(count color)~
Perform a hue rotation in hsluv space starting with COLOR, generating COUNT colors.
#+BEGIN_src elisp
(ct-rotation-hsluv 6 "#4fa5e8") ;; => ("#4ea5e7" "#e173ec" "#f0798f" "#bc9a43" "#5cb143" "#48ada5")
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/4ea5e7.svg]],[[http://muffin.app.neeasade.net/colorsquare/e173ec.svg]],[[http://muffin.app.neeasade.net/colorsquare/f0798f.svg]],[[http://muffin.app.neeasade.net/colorsquare/bc9a43.svg]],[[http://muffin.app.neeasade.net/colorsquare/5cb143.svg]],[[http://muffin.app.neeasade.net/colorsquare/48ada5.svg]]
#+END_quote
**** ct-rotation-hpluv ~(count color)~
Perform a hue rotation in hpluv space starting with COLOR, generating COUNT colors.
#+BEGIN_src elisp
(ct-rotation-hpluv 4 "#4fa5e8") ;; => ("#72a2d2" "#d585b4" "#b89a59" "#43b087")
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/72a2d2.svg]],[[http://muffin.app.neeasade.net/colorsquare/d585b4.svg]],[[http://muffin.app.neeasade.net/colorsquare/b89a59.svg]],[[http://muffin.app.neeasade.net/colorsquare/43b087.svg]]
#+END_quote
**** ct-rotation-hsv ~(count color)~
Perform a hue rotation in hsv space starting with COLOR, generating COUNT colors.
#+BEGIN_src elisp
(ct-rotation-hsv 10 "#4fa5e8") ;; => ("#4ea5e8" "#544ee8" "#b04ee8" "#e84ec3" "#e84e67" "#e8924e" "#e2e84e" "#86e84e" "#4ee873" "#4ee8cf")
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/4ea5e8.svg]],[[http://muffin.app.neeasade.net/colorsquare/544ee8.svg]],[[http://muffin.app.neeasade.net/colorsquare/b04ee8.svg]],[[http://muffin.app.neeasade.net/colorsquare/e84ec3.svg]],[[http://muffin.app.neeasade.net/colorsquare/e84e67.svg]],[[http://muffin.app.neeasade.net/colorsquare/e8924e.svg]],[[http://muffin.app.neeasade.net/colorsquare/e2e84e.svg]],[[http://muffin.app.neeasade.net/colorsquare/86e84e.svg]],[[http://muffin.app.neeasade.net/colorsquare/4ee873.svg]],[[http://muffin.app.neeasade.net/colorsquare/4ee8cf.svg]]
#+END_quote
**** ct-rotation-lch ~(count color)~
Perform a hue rotation in lch space starting with COLOR, generating COUNT colors.
#+BEGIN_src elisp
(ct-rotation-lch 8 "#4fa5e8") ;; => ("#4fa4e8" "#ae91d9" "#df81a9" "#e18672" "#bd9953" "#84a961" "#31b193" "#00b0ca")
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/4fa4e8.svg]],[[http://muffin.app.neeasade.net/colorsquare/ae91d9.svg]],[[http://muffin.app.neeasade.net/colorsquare/df81a9.svg]],[[http://muffin.app.neeasade.net/colorsquare/e18672.svg]],[[http://muffin.app.neeasade.net/colorsquare/bd9953.svg]],[[http://muffin.app.neeasade.net/colorsquare/84a961.svg]],[[http://muffin.app.neeasade.net/colorsquare/31b193.svg]],[[http://muffin.app.neeasade.net/colorsquare/00b0ca.svg]]
#+END_quote
** RGB
https://notes.neeasade.net/color-spaces.html#h-99356355-d54c-41d8-bc1a-6e14e29f42c8
**** ct-make-rgb ~(red green blue)~
Make a rgb color using properties: RED, GREEN, BLUE.
#+BEGIN_src elisp
(ct-make-rgb 31 65 91) ;; => "#4fa5e8"
#+END_src
#+BEGIN_quote
→ [[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]]
#+END_quote
**** ct-get-rgb ~(color)~
Get rgb representation (Red, Green, Blue) of COLOR.
#+BEGIN_src elisp
(ct-get-rgb "#4fa5e8") ;; => (31 65 91)
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → (31 65 91)
#+END_quote
**** ct-get-rgb-r ~(color)~
Get rgb Red value of COLOR.
#+BEGIN_src elisp
(ct-get-rgb-r "#4fa5e8") ;; => 31
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 31
#+END_quote
**** ct-get-rgb-g ~(color)~
Get rgb Green value of COLOR.
#+BEGIN_src elisp
(ct-get-rgb-g "#4fa5e8") ;; => 65
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 65
#+END_quote
**** ct-get-rgb-b ~(color)~
Get rgb Blue value of COLOR.
#+BEGIN_src elisp
(ct-get-rgb-b "#4fa5e8") ;; => 91
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 91
#+END_quote
**** ct-edit-rgb ~(color edit-fn)~
Edit COLOR in the RGB colorspace by calling EDIT-FN with it's RGB properties.
#+BEGIN_src elisp
(ct-edit-rgb "#4fa5e8" (lambda (R G B) (list R 0 0))) ;; => "#4f0000"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/4f0000.svg]]
#+END_quote
**** ct-edit-rgb-b ~(color func-or-val)~
Transform rgb Blue of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-rgb-b "#4fa5e8" (lambda (b) (+ b 50))) ;; => "#4fa4ff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/4fa4ff.svg]]
#+END_quote
**** ct-edit-rgb-b-dec ~(color &optional amount)~
Decrease rgb-b property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-rgb-b-dec "#bbbbbb" 10) ;; => "#bbbba1"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/bbbbbb.svg]] → [[http://muffin.app.neeasade.net/colorsquare/bbbba1.svg]]
#+END_quote
**** ct-edit-rgb-b-inc ~(color &optional amount)~
Increase rgb-b property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-rgb-b-inc "#bbbbbb") ;; => "#bbbbbc"
#+END_src
**** ct-edit-rgb-g ~(color func-or-val)~
Transform rgb Green of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-rgb-g "#4fa5e8" 100) ;; => "#4fffe8"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/4fffe8.svg]]
#+END_quote
**** ct-edit-rgb-g-dec ~(color &optional amount)~
Decrease rgb-g property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-rgb-g-dec "#bbbbbb" 10) ;; => "#bba1bb"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/bbbbbb.svg]] → [[http://muffin.app.neeasade.net/colorsquare/bba1bb.svg]]
#+END_quote
**** ct-edit-rgb-g-inc ~(color &optional amount)~
Increase rgb-g property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-rgb-g-inc "#bbbbbb") ;; => "#bbbcbb"
#+END_src
**** ct-edit-rgb-r ~(color func-or-val)~
Transform rgb Red of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-rgb-r "#4fa5e8" 100) ;; => "#ffa4e8"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/ffa4e8.svg]]
#+END_quote
**** ct-edit-rgb-r-dec ~(color &optional amount)~
Decrease rgb-r property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-rgb-r-dec "#bbbbbb" 10) ;; => "#a1bbbb"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/bbbbbb.svg]] → [[http://muffin.app.neeasade.net/colorsquare/a1bbbb.svg]]
#+END_quote
**** ct-edit-rgb-r-inc ~(color &optional amount)~
Increase rgb-r property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-rgb-r-inc "#bbbbbb") ;; => "#bcbbbb"
#+END_src
** (cie)LAB
https://notes.neeasade.net/color-spaces.html#h-9d5a1a9a-75d3-48f5-bf00-85332d9b023e
**** ct-make-lab ~(lightness a b)~
Make a lab color using properties: LIGHTNESS, A, B.
#+BEGIN_src elisp
(ct-make-lab 65 -5 -41) ;; => "#50a4e6"
#+END_src
#+BEGIN_quote
→ [[http://muffin.app.neeasade.net/colorsquare/50a4e6.svg]]
#+END_quote
**** ct-get-lab ~(color)~
Get lab representation (Lightness, A, B) of COLOR.
#+BEGIN_src elisp
(ct-get-lab "#4fa5e8") ;; => (65 -5 -41)
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → (65 -5 -41)
#+END_quote
**** ct-get-lab-l ~(color)~
Get lab Lightness value of COLOR.
#+BEGIN_src elisp
(ct-get-lab-l "#4fa5e8") ;; => 65
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 65
#+END_quote
**** ct-get-lab-b ~(color)~
Get lab B value of COLOR.
#+BEGIN_src elisp
(ct-get-lab-b "#4fa5e8") ;; => -41
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → -41
#+END_quote
**** ct-get-lab-a ~(color)~
Get lab A value of COLOR.
#+BEGIN_src elisp
(ct-get-lab-a "#4fa5e8") ;; => -5
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → -5
#+END_quote
**** ct-edit-lab ~(color edit-fn)~
Edit COLOR in the cieLAB colorspace by calling EDIT-FN with it's LAB properties.
#+BEGIN_src elisp
(ct-edit-lab "#4fa5e8" (lambda (L A B) (list L -100 -100))) ;; => "#00ccff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/00ccff.svg]]
#+END_quote
**** ct-edit-lab-a ~(color func-or-val)~
Transform lab A of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-lab-a "#4fa5e8" (lambda (a) (- a 20))) ;; => "#00aee7"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/00aee7.svg]]
#+END_quote
**** ct-edit-lab-a-dec ~(color &optional amount)~
Decrease lab-a property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-lab-a-dec "#4fa5e8" 20) ;; => "#00aee7"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/00aee7.svg]]
#+END_quote
**** ct-edit-lab-a-inc ~(color &optional amount)~
Increase lab-a property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-lab-a-inc "#4fa5e8" 20) ;; => "#8c99e8"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/8c99e8.svg]]
#+END_quote
**** ct-edit-lab-b ~(color func-or-val)~
Transform lab B of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-lab-b "#4fa5e8" 100) ;; => "#b79e00"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/b79e00.svg]]
#+END_quote
**** ct-edit-lab-b-dec ~(color &optional amount)~
Decrease lab-b property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-lab-b-dec "#4fa5e8" 20) ;; => "#00a7ff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/00a7ff.svg]]
#+END_quote
**** ct-edit-lab-b-inc ~(color &optional amount)~
Increase lab-b property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-lab-b-inc "#4fa5e8" 20) ;; => "#7aa3c4"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/7aa3c4.svg]]
#+END_quote
**** ct-edit-lab-l ~(color func-or-val)~
Transform lab Lightness of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-lab-l "#4fa5e8" 0) ;; => "#000a3d"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/000a3d.svg]]
#+END_quote
**** ct-edit-lab-l-dec ~(color &optional amount)~
Decrease lab-l property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-lab-l-dec "#4fa5e8") ;; => "#4ea4e7"
#+END_src
**** ct-edit-lab-l-inc ~(color &optional amount)~
Increase lab-l property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-lab-l-inc "#4fa5e8") ;; => "#50a5e8"
#+END_src
** HSL
https://notes.neeasade.net/color-spaces.html#h-43869bc7-a7d1-410f-9341-521974751dac
**** ct-make-hsl ~(hue saturation lightness)~
Make a hsl color using properties: HUE, SATURATION, LIGHTNESS.
#+BEGIN_src elisp
(ct-make-hsl 206 77 61) ;; => "#4ea5e8"
#+END_src
#+BEGIN_quote
→ [[http://muffin.app.neeasade.net/colorsquare/4ea5e8.svg]]
#+END_quote
**** ct-get-hsl ~(color)~
Get hsl representation (Hue, Saturation, Lightness) of COLOR.
#+BEGIN_src elisp
(ct-get-hsl "#4fa5e8") ;; => (206 77 61)
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → (206 77 61)
#+END_quote
**** ct-get-hsl-s ~(color)~
Get hsl Saturation value of COLOR.
#+BEGIN_src elisp
(ct-get-hsl-s "#4fa5e8") ;; => 77
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 77
#+END_quote
**** ct-get-hsl-l ~(color)~
Get hsl Lightness value of COLOR.
#+BEGIN_src elisp
(ct-get-hsl-l "#4fa5e8") ;; => 61
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 61
#+END_quote
**** ct-get-hsl-h ~(color)~
Get hsl Hue value of COLOR.
#+BEGIN_src elisp
(ct-get-hsl-h "#4fa5e8") ;; => 206
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 206
#+END_quote
**** ct-edit-hsl ~(color edit-fn)~
Edit COLOR in the HSL colorspace by calling EDIT-FN with it's HSL properties.
EDIT-FN is called with values in ranges: {0-360, 0-100, 0-100}.
#+BEGIN_src elisp
(ct-edit-hsl "#4fa5e8" (lambda (H S L) (list (+ H 60) 100 L))) ;; => "#8f38ff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/8f38ff.svg]]
#+END_quote
**** ct-edit-hsl-h ~(color func-or-val)~
Transform hsl Hue of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-hsl-h "#4fa5e8" (lambda (H) (+ H 60))) ;; => "#914fe8"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/914fe8.svg]]
#+END_quote
**** ct-edit-hsl-h-dec ~(color &optional amount)~
Decrease hsl-h property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-hsl-h-dec "#4fa5e8") ;; => "#4fa6e8"
#+END_src
**** ct-edit-hsl-h-inc ~(color &optional amount)~
Increase hsl-h property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-hsl-h-inc "#4fa5e8") ;; => "#4fa4e8"
#+END_src
**** ct-edit-hsl-l ~(color func-or-val)~
Transform hsl Lightness of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-hsl-l "#4fa5e8" 0) ;; => "#000000"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/000000.svg]]
#+END_quote
**** ct-edit-hsl-l-dec ~(color &optional amount)~
Decrease hsl-l property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-hsl-l-dec "#4fa5e8") ;; => "#4ea4e7"
#+END_src
**** ct-edit-hsl-l-inc ~(color &optional amount)~
Increase hsl-l property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-hsl-l-inc "#4fa5e8") ;; => "#50a5e8"
#+END_src
**** ct-edit-hsl-s ~(color func-or-val)~
Transform hsl Saturation of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-hsl-s "#4fa5e8" 100) ;; => "#38a7ff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/38a7ff.svg]]
#+END_quote
**** ct-edit-hsl-s-dec ~(color &optional amount)~
Decrease hsl-s property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-hsl-s-dec "#4fa5e8") ;; => "#4fa4e7"
#+END_src
**** ct-edit-hsl-s-inc ~(color &optional amount)~
Increase hsl-s property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-hsl-s-inc "#4fa5e8") ;; => "#4ea5e8"
#+END_src
** HSLuv
https://notes.neeasade.net/color-spaces.html#h-c147b84d-d95b-4d2d-8426-2f96529a8428
**** ct-make-hsluv ~(hue saturation lightness)~
Make a hsluv color using properties: HUE, SATURATION, LIGHTNESS.
#+BEGIN_src elisp
(ct-make-hsluv 243 81 65) ;; => "#4ea4e7"
#+END_src
#+BEGIN_quote
→ [[http://muffin.app.neeasade.net/colorsquare/4ea4e7.svg]]
#+END_quote
**** ct-get-hsluv ~(color)~
Get hsluv representation (Hue, Saturation, Lightness) of COLOR.
#+BEGIN_src elisp
(ct-get-hsluv "#4fa5e8") ;; => (243 81 65)
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → (243 81 65)
#+END_quote
**** ct-get-hsluv-s ~(color)~
Get hsluv Saturation value of COLOR.
#+BEGIN_src elisp
(ct-get-hsluv-s "#4fa5e8") ;; => 81
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 81
#+END_quote
**** ct-get-hsluv-l ~(color)~
Get hsluv Lightness value of COLOR.
#+BEGIN_src elisp
(ct-get-hsluv-l "#4fa5e8") ;; => 65
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 65
#+END_quote
**** ct-get-hsluv-h ~(color)~
Get hsluv Hue value of COLOR.
#+BEGIN_src elisp
(ct-get-hsluv-h "#4fa5e8") ;; => 243
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 243
#+END_quote
**** ct-edit-hsluv ~(color edit-fn)~
Edit COLOR in the HSLuv colorspace by calling EDIT-FN with it's HSL properties.
EDIT-FN is called with values in ranges: {0-360, 0-100, 0-100}.
#+BEGIN_src elisp
(ct-edit-hsluv "#4fa5e8" (lambda (H S L) (list (+ H 60) 100 L))) ;; => "#f160ff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/f160ff.svg]]
#+END_quote
**** ct-edit-hsluv-h ~(color func-or-val)~
Transform hsluv Hue of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-hsluv-h "#4fa5e8" (lambda (H) (+ H 60))) ;; => "#e173ec"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/e173ec.svg]]
#+END_quote
**** ct-edit-hsluv-h-dec ~(color &optional amount)~
Decrease hsluv-h property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-hsluv-h-dec "#4fa5e8") ;; => "#4ea5e7"
#+END_src
**** ct-edit-hsluv-h-inc ~(color &optional amount)~
Increase hsluv-h property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-hsluv-h-inc "#4fa5e8") ;; => "#4fa4e8"
#+END_src
**** ct-edit-hsluv-l ~(color func-or-val)~
Transform hsluv Lightness of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-hsluv-l "#4fa5e8" 0) ;; => "#000000"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/000000.svg]]
#+END_quote
**** ct-edit-hsluv-l-dec ~(color &optional amount)~
Decrease hsluv-l property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-hsluv-l-dec "#4fa5e8") ;; => "#4ea4e7"
#+END_src
**** ct-edit-hsluv-l-inc ~(color &optional amount)~
Increase hsluv-l property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-hsluv-l-inc "#4fa5e8") ;; => "#4fa5e9"
#+END_src
**** ct-edit-hsluv-s ~(color func-or-val)~
Transform hsluv Saturation of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-hsluv-s "#4fa5e8" 100) ;; => "#00a6f8"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/00a6f8.svg]]
#+END_quote
**** ct-edit-hsluv-s-dec ~(color &optional amount)~
Decrease hsluv-s property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-hsluv-s-dec "#4fa5e8") ;; => "#4fa4e7"
#+END_src
**** ct-edit-hsluv-s-inc ~(color &optional amount)~
Increase hsluv-s property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-hsluv-s-inc "#4fa5e8") ;; => "#4ea5e8"
#+END_src
** (cie)LCH
https://notes.neeasade.net/color-spaces.html#h-c4f93e1f-4fa6-4ebc-99c1-18b6de0ef413
**** ct-make-lch ~(lightness chroma hue)~
Make a lch color using properties: LIGHTNESS, CHROMA, HUE.
#+BEGIN_src elisp
(ct-make-lch 65 42 -97) ;; => "#4da4e7"
#+END_src
#+BEGIN_quote
→ [[http://muffin.app.neeasade.net/colorsquare/4da4e7.svg]]
#+END_quote
**** ct-get-lch ~(color)~
Get lch representation (Lightness, Chroma, Hue) of COLOR.
#+BEGIN_src elisp
(ct-get-lch "#4fa5e8") ;; => (65 42 -97)
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → (65 42 -97)
#+END_quote
**** ct-get-lch-l ~(color)~
Get lch Lightness value of COLOR.
#+BEGIN_src elisp
(ct-get-lch-l "#4fa5e8") ;; => 65
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 65
#+END_quote
**** ct-get-lch-h ~(color)~
Get lch Hue value of COLOR.
#+BEGIN_src elisp
(ct-get-lch-h "#4fa5e8") ;; => -97
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → -97
#+END_quote
**** ct-get-lch-c ~(color)~
Get lch Chroma value of COLOR.
#+BEGIN_src elisp
(ct-get-lch-c "#4fa5e8") ;; => 42
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 42
#+END_quote
**** ct-edit-lch ~(color edit-fn)~
Edit COLOR in the cieLCH colorspace by calling EDIT-FN with it's LCH properties.
EDIT-FN is called with values in ranges: {0-100, 0-100, 0-360}.
#+BEGIN_src elisp
(ct-edit-lch "#4fa5e8" (lambda (L C H) (list L 100 (+ H 90)))) ;; => "#ff00b8"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/ff00b8.svg]]
#+END_quote
**** ct-edit-lch-c ~(color func-or-val)~
Transform lch Chroma of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-lch-c "#4fa5e8" 100) ;; => "#00b0ff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/00b0ff.svg]]
#+END_quote
**** ct-edit-lch-c-dec ~(color &optional amount)~
Decrease lch-c property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-lch-c-dec "#4fa5e8") ;; => "#4fa4e7"
#+END_src
**** ct-edit-lch-c-inc ~(color &optional amount)~
Increase lch-c property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-lch-c-inc "#4fa5e8") ;; => "#4ea5e8"
#+END_src
**** ct-edit-lch-h ~(color func-or-val)~
Transform lch Hue of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-lch-h "#4fa5e8" (lambda (H) (+ H 90))) ;; => "#df81a9"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/df81a9.svg]]
#+END_quote
**** ct-edit-lch-h-dec ~(color &optional amount)~
Decrease lch-h property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-lch-h-dec "#4fa5e8") ;; => "#4ea5e7"
#+END_src
**** ct-edit-lch-h-inc ~(color &optional amount)~
Increase lch-h property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-lch-h-inc "#4fa5e8") ;; => "#4fa4e8"
#+END_src
**** ct-edit-lch-l ~(color func-or-val)~
Transform lch Lightness of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-lch-l "#4fa5e8" 100) ;; => "#baffff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/baffff.svg]]
#+END_quote
**** ct-edit-lch-l-dec ~(color &optional amount)~
Decrease lch-l property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-lch-l-dec "#4fa5e8") ;; => "#4ea4e7"
#+END_src
**** ct-edit-lch-l-inc ~(color &optional amount)~
Increase lch-l property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-lch-l-inc "#4fa5e8") ;; => "#50a5e8"
#+END_src
** HSV
https://en.wikipedia.org/wiki/HSL_and_HSV
**** ct-make-hsv ~(hue saturation value)~
Make a hsv color using properties: HUE, SATURATION, VALUE.
#+BEGIN_src elisp
(ct-make-hsv 206 66 91) ;; => "#4ea5e8"
#+END_src
#+BEGIN_quote
→ [[http://muffin.app.neeasade.net/colorsquare/4ea5e8.svg]]
#+END_quote
**** ct-get-hsv ~(color)~
Get hsv representation (Hue, Saturation, Value) of COLOR.
#+BEGIN_src elisp
(ct-get-hsv "#4fa5e8") ;; => (206 66 91)
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → (206 66 91)
#+END_quote
**** ct-get-hsv-v ~(color)~
Get hsv Value value of COLOR.
#+BEGIN_src elisp
(ct-get-hsv-v "#4fa5e8") ;; => 91
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 91
#+END_quote
**** ct-get-hsv-s ~(color)~
Get hsv Saturation value of COLOR.
#+BEGIN_src elisp
(ct-get-hsv-s "#4fa5e8") ;; => 66
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 66
#+END_quote
**** ct-get-hsv-h ~(color)~
Get hsv Hue value of COLOR.
#+BEGIN_src elisp
(ct-get-hsv-h "#4fa5e8") ;; => 206
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 206
#+END_quote
**** ct-edit-hsv ~(color edit-fn)~
Edit COLOR in the HSV colorspace by calling EDIT-FN with it's HSV properties.
EDIT-FN is called with values in ranges: {0-360, 0-100, 0-100}.
#+BEGIN_src elisp
(ct-edit-hsv "#4fa5e8" (lambda (H S V) (list H 20 100))) ;; => "#cce8ff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/cce8ff.svg]]
#+END_quote
**** ct-edit-hsv-h ~(color func-or-val)~
Transform hsv Hue of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-hsv-h "#4fa5e8" (-partial #'+ 30)) ;; => "#4e58e8"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/4e58e8.svg]]
#+END_quote
**** ct-edit-hsv-h-dec ~(color &optional amount)~
Decrease hsv-h property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-hsv-h-dec "#4fa5e8") ;; => "#4ea5e8"
#+END_src
**** ct-edit-hsv-h-inc ~(color &optional amount)~
Increase hsv-h property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-hsv-h-inc "#4fa5e8") ;; => "#4ea4e8"
#+END_src
**** ct-edit-hsv-s ~(color func-or-val)~
Transform hsv Saturation of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-hsv-s "#4fa5e8" 20) ;; => "#b9d3e8"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/b9d3e8.svg]]
#+END_quote
**** ct-edit-hsv-s-dec ~(color &optional amount)~
Decrease hsv-s property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-hsv-s-dec "#4fa5e8") ;; => "#50a5e8"
#+END_src
**** ct-edit-hsv-s-inc ~(color &optional amount)~
Increase hsv-s property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-hsv-s-inc "#4fa5e8") ;; => "#4ea4e8"
#+END_src
**** ct-edit-hsv-v ~(color func-or-val)~
Transform hsv Value of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-hsv-v "#4fa5e8" 100) ;; => "#56b5ff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/56b5ff.svg]]
#+END_quote
**** ct-edit-hsv-v-dec ~(color &optional amount)~
Decrease hsv-v property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-hsv-v-dec "#4fa5e8") ;; => "#4ea4e7"
#+END_src
**** ct-edit-hsv-v-inc ~(color &optional amount)~
Increase hsv-v property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-hsv-v-inc "#4fa5e8") ;; => "#4fa5e9"
#+END_src
** HPLUV
https://ajalt.github.io/colormath/api/colormath/com.github.ajalt.colormath.model/-h-p-luv/index.html
**** ct-make-hpluv ~(hue percentage-saturation lightness)~
Make a hpluv color using properties: HUE, PERCENTAGE-SATURATION, LIGHTNESS.
#+BEGIN_src elisp
(ct-make-hpluv 243 143 65) ;; => "#72a1d1"
#+END_src
#+BEGIN_quote
→ [[http://muffin.app.neeasade.net/colorsquare/72a1d1.svg]]
#+END_quote
**** ct-get-hpluv ~(color)~
Get hpluv representation (Hue, Percentage-Saturation, Lightness) of COLOR.
#+BEGIN_src elisp
(ct-get-hpluv "#4fa5e8") ;; => (243 143 65)
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → (243 143 65)
#+END_quote
**** ct-get-hpluv-p ~(color)~
Get hpluv Percentage-Saturation value of COLOR.
#+BEGIN_src elisp
(ct-get-hpluv-p "#4fa5e8") ;; => 143
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 143
#+END_quote
**** ct-get-hpluv-l ~(color)~
Get hpluv Lightness value of COLOR.
#+BEGIN_src elisp
(ct-get-hpluv-l "#4fa5e8") ;; => 65
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 65
#+END_quote
**** ct-get-hpluv-h ~(color)~
Get hpluv Hue value of COLOR.
#+BEGIN_src elisp
(ct-get-hpluv-h "#4fa5e8") ;; => 243
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 243
#+END_quote
**** ct-edit-hpluv ~(color edit-fn)~
Edit COLOR in the HPLuv colorspace by calling EDIT-FN with it's HPL properties.
EDIT-FN is called with values in ranges: {0-360, 0-100, 0-100}.
#+BEGIN_src elisp
(ct-edit-hpluv "#4fa5e8" (lambda (H P L) (list H 100 L))) ;; => "#72a2d2"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/72a2d2.svg]]
#+END_quote
**** ct-edit-hpluv-h ~(color func-or-val)~
Transform hpluv Hue of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-hpluv-h "#4fa5e8" 0) ;; => "#d78798"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/d78798.svg]]
#+END_quote
**** ct-edit-hpluv-h-dec ~(color &optional amount)~
Decrease hpluv-h property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-hpluv-h-dec "#4fa5e8") ;; => "#71a2d2"
#+END_src
**** ct-edit-hpluv-h-inc ~(color &optional amount)~
Increase hpluv-h property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-hpluv-h-inc "#4fa5e8") ;; => "#72a2d2"
#+END_src
**** ct-edit-hpluv-l ~(color func-or-val)~
Transform hpluv Lightness of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-hpluv-l "#4fa5e8" 100) ;; => "#feffff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/feffff.svg]]
#+END_quote
**** ct-edit-hpluv-l-dec ~(color &optional amount)~
Decrease hpluv-l property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-hpluv-l-dec "#4fa5e8") ;; => "#71a2d2"
#+END_src
**** ct-edit-hpluv-l-inc ~(color &optional amount)~
Increase hpluv-l property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-hpluv-l-inc "#4fa5e8") ;; => "#72a3d3"
#+END_src
**** ct-edit-hpluv-p ~(color func-or-val)~
Transform hpluv Percentage-Saturation of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-hpluv-p "#4fa5e8" 100) ;; => "#72a2d2"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/72a2d2.svg]]
#+END_quote
**** ct-edit-hpluv-p-dec ~(color &optional amount)~
Decrease hpluv-p property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-hpluv-p-dec "#4fa5e8") ;; => "#72a2d2"
#+END_src
**** ct-edit-hpluv-p-inc ~(color &optional amount)~
Increase hpluv-p property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-hpluv-p-inc "#4fa5e8") ;; => "#72a2d2"
#+END_src
** okLAB
https://bottosson.github.io/posts/oklab/
**** ct-make-oklab ~(lightness a b)~
Make a oklab color using properties: LIGHTNESS, A, B.
#+BEGIN_src elisp
(ct-make-oklab 70 -5 -12) ;; => "#54a4ea"
#+END_src
#+BEGIN_quote
→ [[http://muffin.app.neeasade.net/colorsquare/54a4ea.svg]]
#+END_quote
**** ct-get-oklab ~(color)~
Get oklab representation (Lightness, A, B) of COLOR.
#+BEGIN_src elisp
(ct-get-oklab "#4fa5e8") ;; => (70 -5 -12)
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → (70 -5 -12)
#+END_quote
**** ct-get-oklab-l ~(color)~
Get oklab Lightness value of COLOR.
#+BEGIN_src elisp
(ct-get-oklab-l "#4fa5e8") ;; => 70
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → 70
#+END_quote
**** ct-get-oklab-a ~(color)~
Get oklab A value of COLOR.
#+BEGIN_src elisp
(ct-get-oklab-a "#4fa5e8") ;; => -5
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → -5
#+END_quote
**** ct-get-oklab-b ~(color)~
Get oklab B value of COLOR.
#+BEGIN_src elisp
(ct-get-oklab-b "#4fa5e8") ;; => -12
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → -12
#+END_quote
**** ct-edit-oklab ~(color edit-fn)~
Edit COLOR in by calling edit-fn with it's okLAB properties.
#+BEGIN_src elisp
(ct-edit-oklab "#4fa5e8" (lambda (L A B) (list L 100 B))) ;; => "#ff00c9"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/ff00c9.svg]]
#+END_quote
**** ct-edit-oklab-l ~(color func-or-val)~
Transform oklab Lightness of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-oklab-l "#4fa5e8" 100) ;; => "#b1ffff"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/b1ffff.svg]]
#+END_quote
**** ct-edit-oklab-l-dec ~(color &optional amount)~
Decrease oklab-l property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-oklab-l-dec "#4fa5e8") ;; => "#4ea4e7"
#+END_src
**** ct-edit-oklab-l-inc ~(color &optional amount)~
Increase oklab-l property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-oklab-l-inc "#4fa5e8") ;; => "#4fa5e9"
#+END_src
**** ct-edit-oklab-a ~(color func-or-val)~
Transform oklab A of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-oklab-a "#4fa5e8" 0) ;; => "#8199e6"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/8199e6.svg]]
#+END_quote
**** ct-edit-oklab-a-dec ~(color &optional amount)~
Decrease oklab-a property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-oklab-a-dec "#4fa5e8") ;; => "#4da5e8"
#+END_src
**** ct-edit-oklab-a-inc ~(color &optional amount)~
Increase oklab-a property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-oklab-a-inc "#4fa5e8") ;; => "#50a4e7"
#+END_src
**** ct-edit-oklab-b ~(color func-or-val)~
Transform oklab B of COLOR using FUNC-OR-VAL.
#+BEGIN_src elisp
(ct-edit-oklab-b "#4fa5e8" 100) ;; => "#ff0000"
#+END_src
#+BEGIN_quote
[[http://muffin.app.neeasade.net/colorsquare/4fa5e8.svg]] → [[http://muffin.app.neeasade.net/colorsquare/ff0000.svg]]
#+END_quote
**** ct-edit-oklab-b-dec ~(color &optional amount)~
Decrease oklab-b property of COLOR by AMOUNT (defaults to minimum decrease amount).
#+BEGIN_src elisp
(ct-edit-oklab-b-dec "#4fa5e8") ;; => "#4ea4e8"
#+END_src
**** ct-edit-oklab-b-inc ~(color &optional amount)~
Increase oklab-b property of COLOR by AMOUNT (defaults to minimum increase amount).
#+BEGIN_src elisp
(ct-edit-oklab-b-inc "#4fa5e8") ;; => "#4fa5e7"
#+END_src** Gotchas
Some colors as defined in color spaces may not be represented in the RGB space (and vice versa). The edit functions clamp values going out. One example is the narrowly scoped ~hpluv~ space:
#+begin_src emacs-lisp
(ct-get-hpluv "#dd00cc");; That p value is way out of range!
;; => (314.3830496716472 282.01497572464575 51.53528501195089);; notice we ask for the same color back, but the edit functions clamp the output to maximum HPL values:
(ct-edit-hpluv "#dd00cc" 'list);; => "#9f6898"
#+end_src** Testing
Right now testing happens by using the `ct-make-*` functions(these use the edit functions, which make up the basis for all the color space functions) against:
- https://css.land/lch/
- http://colorizer.org/** Related links
Emacs color libraries:
- https://github.com/emacs-mirror/emacs/blob/master/lisp/color.el
- https://github.com/emacsfodder/kurecolor
- https://github.com/yurikhan/yk-color
- https://github.com/hsluv/hsluv-emacsGeneral color knowledge:
- http://colorizer.org/
- https://peteroupc.github.io/colorgen.html
- https://www.w3.org/TR/WCAG20/#relativeluminancedef
- https://en.wikipedia.org/wiki/CIELAB_color_space