summaryrefslogtreecommitdiffstats
path: root/src/functions/_colors.scss
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2024-06-24 17:07:19 +0200
committerVolpeon <git@volpeon.ink>2024-06-24 17:07:19 +0200
commitf1c517da618ba92e537e8e4856203fe988df8636 (patch)
treeafb774c56d7b6340c902dd02e886075bd5a749e3 /src/functions/_colors.scss
parentUpdate (diff)
downloadiro-design-f1c517da618ba92e537e8e4856203fe988df8636.tar.gz
iro-design-f1c517da618ba92e537e8e4856203fe988df8636.tar.bz2
iro-design-f1c517da618ba92e537e8e4856203fe988df8636.zip
Update
Diffstat (limited to 'src/functions/_colors.scss')
-rw-r--r--src/functions/_colors.scss180
1 files changed, 0 insertions, 180 deletions
diff --git a/src/functions/_colors.scss b/src/functions/_colors.scss
deleted file mode 100644
index d3c0035..0000000
--- a/src/functions/_colors.scss
+++ /dev/null
@@ -1,180 +0,0 @@
1/* stylelint-disable scss/dollar-variable-pattern */
2/* stylelint-disable scss/at-function-pattern */
3
4@use 'sass:color';
5@use 'sass:list';
6@use 'sass:map';
7@use 'sass:math';
8@use 'sass:meta';
9@use '@oddbird/blend/sass/convert' as blend-convert;
10@use '@oddbird/blend/sass/utils/pow';
11
12$SA98G: (
13 mainTRC: 2.4,
14
15 sRco: 0.2126729,
16 sGco: 0.7151522,
17 sBco: 0.0721750,
18
19 normBG: 0.56,
20 normTXT: 0.57,
21 revTXT: 0.62,
22 revBG: 0.65,
23
24 blkThrs: 0.022,
25 blkClmp: 1.414,
26 scaleBoW: 1.14,
27 scaleWoB: 1.14,
28 loBoWoffset: 0.027,
29 loWoBoffset: 0.027,
30 deltaYmin: 0.0005,
31 loClip: 0.0001,
32
33 mFactor: 1.94685544331710,
34 mOffsetIn: 0.03873938165714010,
35 mExpAdj: 0.2833433964208690,
36 mOffsetOut: 0.3128657958707580,
37);
38
39@function lin_sRGB_to_Oklab($color) {
40 $r_: list.nth($color, 1);
41 $g_: list.nth($color, 2);
42 $b_: list.nth($color, 3);
43
44 $l: pow.cbrt(0.4122214708 * $r_ + 0.5363325363 * $g_ + 0.0514459929 * $b_);
45 $m: pow.cbrt(0.2119034982 * $r_ + 0.6806995451 * $g_ + 0.1073969566 * $b_);
46 $s: pow.cbrt(0.0883024619 * $r_ + 0.2817188376 * $g_ + 0.6299787005 * $b_);
47
48 @return (
49 0.2104542553 * $l + 0.7936177850 * $m - 0.0040720468 * $s,
50 1.9779984951 * $l - 2.4285922050 * $m + 0.4505937099 * $s,
51 0.0259040371 * $l + 0.7827717662 * $m - 0.8086757660 * $s,
52 );
53}
54
55@function Oklab_to_lin_sRGB($color) {
56 $l_: list.nth($color, 1);
57 $a_: list.nth($color, 2);
58 $b_: list.nth($color, 3);
59
60 $l: $l_ + 0.3963377774 * $a_ + 0.2158037573 * $b_;
61 $m: $l_ - 0.1055613458 * $a_ - 0.0638541728 * $b_;
62 $s: $l_ - 0.0894841775 * $a_ - 1.2914855480 * $b_;
63
64 $l: $l * $l * $l;
65 $m: $m * $m * $m;
66 $s: $s * $s * $s;
67
68 @return (
69 4.0767416621 * $l - 3.3077115913 * $m + 0.2309699292 * $s,
70 -1.2684380046 * $l + 2.6097574011 * $m - 0.3413193965 * $s,
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 )
86 );
87}
88
89@function apca_sRGB_to_Y($color) {
90 @return map.get($SA98G, sRco) * math.pow(math.div(color.red($color), 255), map.get($SA98G, mainTRC)) +
91 map.get($SA98G, sGco) * math.pow(math.div(color.green($color), 255), map.get($SA98G, mainTRC)) +
92 map.get($SA98G, sBco) * math.pow(math.div(color.blue($color), 255), map.get($SA98G, mainTRC));
93}
94
95@function apca_Y_to_sRGB($y) {
96 $c: math.round(math.pow($y, math.div(1, map.get($SA98G, mainTRC))) * 255);
97 @return rgb($c, $c, $c);
98}
99
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
107 @if $txtY <= map.get($SA98G, blkThrs) {
108 $txtY: $txtY + math.pow(map.get($SA98G, blkThrs) - $txtY, map.get($SA98G, blkClmp));
109 }
110 @if $bgY <= map.get($SA98G, blkThrs) {
111 $bgY: $bgY + math.pow(map.get($SA98G, blkThrs) - $bgY, map.get($SA98G, blkClmp));
112 }
113
114 @if math.abs($bgY - $txtY) < map.get($SA98G, deltaYmin) {
115 @return 0;
116 }
117
118 $outputContrast: 0;
119
120 @if $bgY > $txtY {
121 $SAPC: map.get($SA98G, scaleBoW) * (math.pow($bgY, map.get($SA98G, normBG)) - math.pow($txtY, map.get($SA98G, normTXT)));
122
123 @if $SAPC >= map.get($SA98G, loClip) {
124 $outputContrast: $SAPC - map.get($SA98G, loBoWoffset);
125 }
126 } @else {
127 $SAPC: map.get($SA98G, scaleWoB) * (math.pow($bgY, map.get($SA98G, revBG)) - math.pow($txtY, map.get($SA98G, revTXT)));
128
129 @if $SAPC <= -1 * map.get($SA98G, loClip) {
130 $outputContrast: $SAPC + map.get($SA98G, loWoBoffset);
131 }
132 }
133
134 @return $outputContrast * 100.0;
135}
136
137@function apcaReverse($contrast, $knownY, $knownType: 'bg') {
138 $unknownY: $knownY;
139
140 $knownExp: 0;
141 $unknownExp: 0;
142
143 $scale: map.get($SA98G, if($contrast > 0, scaleBoW, scaleWoB));
144 $offset: map.get($SA98G, if($contrast > 0, loBoWoffset, loWoBoffset));
145
146 $contrast: math.div($contrast * 0.01 + $offset, $scale);
147
148 @if $knownY <= map.get($SA98G, blkThrs) {
149 $knownY: $knownY + math.pow(map.get($SA98G, blkThrs) - $knownY, map.get($SA98G, blkClmp));
150 }
151
152 @if $knownType == 'bg' {
153 $knownExp: map.get($SA98G, if($contrast > 0, normBG, revBG));
154 $unknownExp: map.get($SA98G, if($contrast > 0, normTXT, revTXT));
155 $unknownY: math.pow(math.pow($knownY, $knownExp) - $contrast, math.div(1, $unknownExp));
156 } @else {
157 $knownExp: map.get($SA98G, if($contrast > 0, normTXT, revTXT));
158 $unknownExp: map.get($SA98G, if($contrast > 0, normBG, revBG));
159 $unknownY: math.pow($contrast + math.pow($knownY, $knownExp), math.div(1, $unknownExp));
160 }
161
162 @if '#{$unknownY}' == '#{math.sqrt(-1)}' {
163 @return false;
164 }
165
166 @if $unknownY > 1.06 or $unknownY < 0 {
167 @return false;
168 }
169
170 @if $unknownY <= map.get($SA98G, blkThrs) {
171 $unknownY: math.pow(
172 ($unknownY + map.get($SA98G, mOffsetIn)) * map.get($SA98G, mFactor),
173 math.div(map.get($SA98G, mExpAdj), map.get($SA98G, blkClmp))
174 ) * math.div(1, map.get($SA98G, mFactor)) - map.get($SA98G, mOffsetOut);
175 }
176
177 $unknownY: math.max(math.min($unknownY, 1), 0);
178
179 @return $unknownY;
180}