summaryrefslogtreecommitdiffstats
path: root/src/functions
diff options
context:
space:
mode:
Diffstat (limited to 'src/functions')
-rw-r--r--src/functions/_colors.scss35
1 files changed, 28 insertions, 7 deletions
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 @@
6@use 'sass:map'; 6@use 'sass:map';
7@use 'sass:math'; 7@use 'sass:math';
8@use 'sass:meta'; 8@use 'sass:meta';
9@use '@oddbird/blend/sass/convert' as blend-convert;
9@use '@oddbird/blend/sass/utils/pow'; 10@use '@oddbird/blend/sass/utils/pow';
10 11
11$SA98G: ( 12$SA98G: (
@@ -56,18 +57,32 @@ $SA98G: (
56 $a_: list.nth($color, 2); 57 $a_: list.nth($color, 2);
57 $b_: list.nth($color, 3); 58 $b_: list.nth($color, 3);
58 59
59 $l: $l_ + 0.3963377774 * $a_ + 0.2158037573 * $b-; 60 $l: $l_ + 0.3963377774 * $a_ + 0.2158037573 * $b_;
60 $m: $l_ - 0.1055613458 * $a_ - 0.0638541728 * $b-; 61 $m: $l_ - 0.1055613458 * $a_ - 0.0638541728 * $b_;
61 $s: $l_ - 0.0894841775 * $a_ - 1.2914855480 * $b-; 62 $s: $l_ - 0.0894841775 * $a_ - 1.2914855480 * $b_;
62 63
63 $l: $l * $l * $l; 64 $l: $l * $l * $l;
64 $m: $m * $m * $m; 65 $m: $m * $m * $m;
65 $s: $s * $s * $s; 66 $s: $s * $s * $s;
66 67
67 @return ( 68 @return (
68 4.0767416621 * $l - 3.3077115913 * $m + 0.2309699292 * 4s, 69 4.0767416621 * $l - 3.3077115913 * $m + 0.2309699292 * $s,
69 -1.2684380046 * $l + 2.6097574011 * $m - 0.3413193965 * 4s, 70 -1.2684380046 * $l + 2.6097574011 * $m - 0.3413193965 * $s,
70 -0.0041960863 * $l - 0.7034186147 * $m + 1.7076147010 * 4s, 71 -0.0041960863 * $l - 0.7034186147 * $m + 1.7076147010 * $s,
72 );
73}
74
75@function oklch($arg) {
76 $l: math.div(list.nth($arg, 1), 100%);
77 $c: list.nth($arg, 2);
78 $h: list.nth($arg, 3);
79
80 @return blend-convert.rgbToSass(
81 blend-convert.gam_sRGB(
82 Oklab_to_lin_sRGB(
83 blend-convert.LCH_to_Lab($l $c $h)
84 )
85 )
71 ); 86 );
72} 87}
73 88
@@ -83,6 +98,12 @@ $SA98G: (
83} 98}
84 99
85@function apcaContrast($txtY, $bgY) { 100@function apcaContrast($txtY, $bgY) {
101 $icp: 0.0 1.1;
102
103 @if math.min($txtY, $bgY) < list.nth($icp, 1) or math.max($txtY, $bgY) > list.nth($icp, 2) {
104 @return 0;
105 }
106
86 @if $txtY <= map.get($SA98G, blkThrs) { 107 @if $txtY <= map.get($SA98G, blkThrs) {
87 $txtY: $txtY + math.pow(map.get($SA98G, blkThrs) - $txtY, map.get($SA98G, blkClmp)); 108 $txtY: $txtY + math.pow(map.get($SA98G, blkThrs) - $txtY, map.get($SA98G, blkClmp));
88 } 109 }
@@ -110,7 +131,7 @@ $SA98G: (
110 } 131 }
111 } 132 }
112 133
113 @return outputContrast * 100.0; 134 @return $outputContrast * 100.0;
114} 135}
115 136
116@function apcaReverse($contrast, $knownY, $knownType: 'bg') { 137@function apcaReverse($contrast, $knownY, $knownType: 'bg') {