Skip to content

Commit

Permalink
Migrate to cl-colors-ng.
Browse files Browse the repository at this point in the history
Closes #3566.
  • Loading branch information
aadcg committed Jan 17, 2025
1 parent 07a2972 commit fdef97f
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@
path = _build/cl-electron
url = https://github.com/atlas-engineer/cl-electron/
shallow = true
[submodule "_build/cl-colors2"]
path = _build/cl-colors2
url = https://codeberg.org/cage/cl-colors2.git
[submodule "_build/cl-colors-ng"]
path = _build/cl-colors-ng
url = https://codeberg.org/cage/cl-colors-ng.git
shallow = true
1 change: 1 addition & 0 deletions _build/cl-colors-ng
Submodule cl-colors-ng added at 310e64
1 change: 0 additions & 1 deletion _build/cl-colors2
Submodule cl-colors2 deleted from f77913
14 changes: 7 additions & 7 deletions libraries/theme/utilities.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@

(in-package :theme)

(serapeum:-> relative-luminance ((or string integer cl-colors2:rgb cl-colors2:hsv))
(serapeum:-> relative-luminance ((or string integer cl-colors-ng:rgb cl-colors-ng:hsv))
real)
(defun relative-luminance (color)
"Compute relative luminance of COLOR."
;; See https://www.w3.org/WAI/GL/wiki/Relative_luminance
(loop for const in '(0.2126 0.7152 0.0722)
for rgb-component in (list (cl-colors2:rgb-red (cl-colors2:as-rgb color))
(cl-colors2:rgb-green (cl-colors2:as-rgb color))
(cl-colors2:rgb-blue (cl-colors2:as-rgb color)))
for rgb-component in (list (cl-colors-ng:rgb-red (cl-colors-ng:as-rgb color))
(cl-colors-ng:rgb-green (cl-colors-ng:as-rgb color))
(cl-colors-ng:rgb-blue (cl-colors-ng:as-rgb color)))
sum (* const (if (<= rgb-component 0.04045)
(/ rgb-component 12.92)
(expt (/ (+ rgb-component 0.055) 1.055) 2.4)))))

(serapeum:-> contrast-ratio ((or string integer cl-colors2:rgb cl-colors2:hsv)
(or string integer cl-colors2:rgb cl-colors2:hsv))
(serapeum:-> contrast-ratio ((or string integer cl-colors-ng:rgb cl-colors-ng:hsv)
(or string integer cl-colors-ng:rgb cl-colors-ng:hsv))
(real 0 21)) ; Ratio between black and white.
(export-always 'contrast-ratio)
(defun contrast-ratio (color1 color2)
Expand All @@ -27,7 +27,7 @@
(+ (relative-luminance color2) 0.05))))
(max ratio (/ ratio))))

(serapeum:-> contrasting-color ((or string integer cl-colors2:rgb cl-colors2:hsv)) string)
(serapeum:-> contrasting-color ((or string integer cl-colors-ng:rgb cl-colors-ng:hsv)) string)
(export-always 'contrasting-color)
(defun contrasting-color (color)
"Determine whether black or white best contrasts with COLOR."
Expand Down
4 changes: 2 additions & 2 deletions nyxt.asd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
bordeaux-threads
calispel
cl-base64
cl-colors2
cl-colors-ng
cl-gopher
cl-json
cl-ppcre
Expand Down Expand Up @@ -495,7 +495,7 @@
:defsystem-depends-on ("nasdf")
:class :nasdf-system
:depends-on (alexandria
cl-colors2
cl-colors-ng
lass
nclasses
serapeum)
Expand Down
14 changes: 7 additions & 7 deletions source/color.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
(defvar copy-actions
(list (lambda-command copy-as-hex* (colors)
"Copy the color as hex #XXXXXX string."
(let ((hex (cl-colors2:print-hex (first colors))))
(let ((hex (cl-colors-ng:print-hex (first colors))))
(ffi-buffer-copy (current-buffer) hex)
(echo "~s copied to clipboard." hex)))
(lambda-command copy-as-rgb* (colors)
"Copy the color as CSS rgb() function string."
(let ((rgb (cl-colors2:print-css-rgb/a (first colors))))
(let ((rgb (cl-colors-ng:print-css-rgb/a (first colors))))
(ffi-buffer-copy (current-buffer) rgb)
(echo "Copied ~a to clipboard!" rgb)))
(lambda-command copy-as-hsl* (colors)
"Copy the color as CSS hsl() function string."
(let ((hsl (cl-colors2:print-css-hsl (first colors))))
(let ((hsl (cl-colors-ng:print-css-hsl (first colors))))
(ffi-buffer-copy (current-buffer) hsl)
(echo "Copied ~a to clipboard!" hsl)))))

Expand All @@ -55,7 +55,7 @@
(prompter:filter-postprocessor
(lambda (suggestions source input-color)
(unless (str:empty? input-color) (sleep 0.2))
(append (when (ignore-errors (cl-colors2:as-rgb input-color))
(append (when (ignore-errors (cl-colors-ng:as-rgb input-color))
(list (make-instance 'prompter:suggestion
:value input-color
:attributes (prompter:object-attributes input-color source))))
Expand All @@ -75,9 +75,9 @@ rgb()/hsl() CSS functions representing them."))
color (theme:contrasting-color color) (theme:contrasting-color color))
string))))
`(("Color" ,(display color))
("HEX" ,(display (cl-colors2:print-hex color)))
("RGB" ,(display (cl-colors2:print-css-rgb/a color)))
("HSL" ,(display (cl-colors2:print-css-hsl color))))))
("HEX" ,(display (cl-colors-ng:print-hex color)))
("RGB" ,(display (cl-colors-ng:print-css-rgb/a color)))
("HSL" ,(display (cl-colors-ng:print-css-hsl color))))))

(define-command-global pick-color ()
"Pick a color and copy it to clipboard.
Expand Down
4 changes: 2 additions & 2 deletions source/mode/hint.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ A positive value shifts to the bottom.")
"The style of the hint overlays."
(theme:themed-css (theme *browser*)
`(".nyxt-hint"
:background-color ,(cl-colors2:print-hex theme:background-color- :alpha 0.925)
:background-color ,(cl-colors-ng:print-hex theme:background-color- :print-alpha 0.925)
:color ,theme:on-background-color
:font-family ,theme:monospace-font-family
:font-size ".85rem"
Expand All @@ -92,7 +92,7 @@ A positive value shifts to the bottom.")
(if (eq (x-placement mode) :right) -100 0))
(y-translation mode))
:padding "0px 0.3em"
:border-color ,(cl-colors2:print-hex theme:primary-color- :alpha 0.80)
:border-color ,(cl-colors-ng:print-hex theme:primary-color- :print-alpha 0.80)
:border-radius "2px"
:border-width "2px"
:border-style "solid"
Expand Down
2 changes: 1 addition & 1 deletion source/prompt-buffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ The following mouse keybindings are available:
:width "100%"
:autofocus "true")
`("#input:focus"
:border-color ,(cl-colors2:print-hex theme:action-color- :alpha 0.40))
:border-color ,(cl-colors-ng:print-hex theme:action-color- :print-alpha 0.40))
'(".source"
:margin-left "10px"
:margin-top "15px")
Expand Down

0 comments on commit fdef97f

Please sign in to comment.