From 029fb64837173b70b31ac579cb005c2995806c49 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Mon, 24 Jun 2024 09:14:43 +0200 Subject: Update --- src/functions/_colors.scss | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'src/functions/_colors.scss') diff --git a/src/functions/_colors.scss b/src/functions/_colors.scss index 265c09a..d3c0035 100644 --- a/src/functions/_colors.scss +++ b/src/functions/_colors.scss @@ -6,6 +6,7 @@ @use 'sass:map'; @use 'sass:math'; @use 'sass:meta'; +@use '@oddbird/blend/sass/convert' as blend-convert; @use '@oddbird/blend/sass/utils/pow'; $SA98G: ( @@ -56,18 +57,32 @@ $SA98G: ( $a_: list.nth($color, 2); $b_: list.nth($color, 3); - $l: $l_ + 0.3963377774 * $a_ + 0.2158037573 * $b-; - $m: $l_ - 0.1055613458 * $a_ - 0.0638541728 * $b-; - $s: $l_ - 0.0894841775 * $a_ - 1.2914855480 * $b-; + $l: $l_ + 0.3963377774 * $a_ + 0.2158037573 * $b_; + $m: $l_ - 0.1055613458 * $a_ - 0.0638541728 * $b_; + $s: $l_ - 0.0894841775 * $a_ - 1.2914855480 * $b_; $l: $l * $l * $l; $m: $m * $m * $m; $s: $s * $s * $s; @return ( - 4.0767416621 * $l - 3.3077115913 * $m + 0.2309699292 * 4s, - -1.2684380046 * $l + 2.6097574011 * $m - 0.3413193965 * 4s, - -0.0041960863 * $l - 0.7034186147 * $m + 1.7076147010 * 4s, + 4.0767416621 * $l - 3.3077115913 * $m + 0.2309699292 * $s, + -1.2684380046 * $l + 2.6097574011 * $m - 0.3413193965 * $s, + -0.0041960863 * $l - 0.7034186147 * $m + 1.7076147010 * $s, + ); +} + +@function oklch($arg) { + $l: math.div(list.nth($arg, 1), 100%); + $c: list.nth($arg, 2); + $h: list.nth($arg, 3); + + @return blend-convert.rgbToSass( + blend-convert.gam_sRGB( + Oklab_to_lin_sRGB( + blend-convert.LCH_to_Lab($l $c $h) + ) + ) ); } @@ -83,6 +98,12 @@ $SA98G: ( } @function apcaContrast($txtY, $bgY) { + $icp: 0.0 1.1; + + @if math.min($txtY, $bgY) < list.nth($icp, 1) or math.max($txtY, $bgY) > list.nth($icp, 2) { + @return 0; + } + @if $txtY <= map.get($SA98G, blkThrs) { $txtY: $txtY + math.pow(map.get($SA98G, blkThrs) - $txtY, map.get($SA98G, blkClmp)); } @@ -110,7 +131,7 @@ $SA98G: ( } } - @return outputContrast * 100.0; + @return $outputContrast * 100.0; } @function apcaReverse($contrast, $knownY, $knownType: 'bg') { -- cgit v1.2.3-70-g09d2