summaryrefslogtreecommitdiffstats
path: root/src/functions/colors
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2024-10-18 18:08:24 +0200
committerVolpeon <git@volpeon.ink>2024-10-18 18:08:24 +0200
commit365c56edcc36b5b92902bac01ce44b43d01e8685 (patch)
tree644611792591a76e605068d0c9e230fad6a633e7 /src/functions/colors
parentRevamped variable management (diff)
downloadiro-design-365c56edcc36b5b92902bac01ce44b43d01e8685.tar.gz
iro-design-365c56edcc36b5b92902bac01ce44b43d01e8685.tar.bz2
iro-design-365c56edcc36b5b92902bac01ce44b43d01e8685.zip
Refactoring
Diffstat (limited to 'src/functions/colors')
-rw-r--r--src/functions/colors/_apca.scss127
-rw-r--r--src/functions/colors/_index.scss1
2 files changed, 0 insertions, 128 deletions
diff --git a/src/functions/colors/_apca.scss b/src/functions/colors/_apca.scss
deleted file mode 100644
index 0c03529..0000000
--- a/src/functions/colors/_apca.scss
+++ /dev/null
@@ -1,127 +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
9$SA98G: (
10 mainTRC: 2.4,
11
12 sRco: .2126729,
13 sGco: .7151522,
14 sBco: .072175,
15
16 normBG: .56,
17 normTXT: .57,
18 revTXT: .62,
19 revBG: .65,
20
21 blkThrs: .022,
22 blkClmp: 1.414,
23 scaleBoW: 1.14,
24 scaleWoB: 1.14,
25 loBoWoffset: .027,
26 loWoBoffset: .027,
27 deltaYmin: .0005,
28 loClip: .0001,
29
30 mFactor: 1.9468554433171,
31 mOffsetIn: .0387393816571401,
32 mExpAdj: .283343396420869,
33 mOffsetOut: .312865795870758,
34);
35
36@function apca_sRGB_to_Y($color) {
37 $rgb: color.to-space($color, rgb);
38
39 @return map.get($SA98G, sRco) * math.pow(math.div(color.channel($rgb, 'red'), 255), map.get($SA98G, mainTRC)) +
40 map.get($SA98G, sGco) * math.pow(math.div(color.channel($rgb, 'green'), 255), map.get($SA98G, mainTRC)) +
41 map.get($SA98G, sBco) * math.pow(math.div(color.channel($rgb, 'blue'), 255), map.get($SA98G, mainTRC));
42}
43
44@function apca_Y_to_sRGB($y) {
45 $c: math.round(math.pow($y, math.div(1, map.get($SA98G, mainTRC))) * 255);
46 @return rgb($c, $c, $c);
47}
48
49@function apcaContrast($txtY, $bgY) {
50 /* stylelint-disable-next-line @stylistic/number-no-trailing-zeros */
51 $icp: .0 1.1;
52
53 @if math.min($txtY, $bgY) < list.nth($icp, 1) or math.max($txtY, $bgY) > list.nth($icp, 2) {
54 @return 0;
55 }
56
57 @if $txtY <= map.get($SA98G, blkThrs) {
58 $txtY: $txtY + math.pow(map.get($SA98G, blkThrs) - $txtY, map.get($SA98G, blkClmp));
59 }
60 @if $bgY <= map.get($SA98G, blkThrs) {
61 $bgY: $bgY + math.pow(map.get($SA98G, blkThrs) - $bgY, map.get($SA98G, blkClmp));
62 }
63
64 @if math.abs($bgY - $txtY) < map.get($SA98G, deltaYmin) {
65 @return 0;
66 }
67
68 $outputContrast: 0;
69
70 @if $bgY > $txtY {
71 $SAPC: map.get($SA98G, scaleBoW) * (math.pow($bgY, map.get($SA98G, normBG)) - math.pow($txtY, map.get($SA98G, normTXT)));
72
73 @if $SAPC >= map.get($SA98G, loClip) {
74 $outputContrast: $SAPC - map.get($SA98G, loBoWoffset);
75 }
76 } @else {
77 $SAPC: map.get($SA98G, scaleWoB) * (math.pow($bgY, map.get($SA98G, revBG)) - math.pow($txtY, map.get($SA98G, revTXT)));
78
79 @if $SAPC <= -1 * map.get($SA98G, loClip) {
80 $outputContrast: $SAPC + map.get($SA98G, loWoBoffset);
81 }
82 }
83
84 @return $outputContrast * 100;
85}
86
87@function apcaReverse($contrast, $knownY, $knownType: 'bg') {
88 $unknownY: $knownY;
89
90 $knownExp: 0;
91 $unknownExp: 0;
92
93 $scale: map.get($SA98G, if($contrast > 0, scaleBoW, scaleWoB));
94 $offset: map.get($SA98G, if($contrast > 0, loBoWoffset, loWoBoffset));
95
96 $contrast: math.div($contrast * .01 + $offset, $scale);
97
98 @if $knownY <= map.get($SA98G, blkThrs) {
99 $knownY: $knownY + math.pow(map.get($SA98G, blkThrs) - $knownY, map.get($SA98G, blkClmp));
100 }
101
102 @if $knownType == 'bg' {
103 $knownExp: map.get($SA98G, if($contrast > 0, normBG, revBG));
104 $unknownExp: map.get($SA98G, if($contrast > 0, normTXT, revTXT));
105 $unknownY: math.pow(math.pow($knownY, $knownExp) - $contrast, math.div(1, $unknownExp));
106 } @else {
107 $knownExp: map.get($SA98G, if($contrast > 0, normTXT, revTXT));
108 $unknownExp: map.get($SA98G, if($contrast > 0, normBG, revBG));
109 $unknownY: math.pow($contrast + math.pow($knownY, $knownExp), math.div(1, $unknownExp));
110 }
111
112 @if '#{$unknownY}' == '#{math.sqrt(-1)}' {
113 @return false;
114 }
115
116 @if $unknownY > 1.06 or $unknownY < 0 {
117 @return false;
118 }
119
120 @if $unknownY <= map.get($SA98G, blkThrs) {
121 $unknownY: math.pow(($unknownY + map.get($SA98G, mOffsetIn)) * map.get($SA98G, mFactor), math.div(map.get($SA98G, mExpAdj), map.get($SA98G, blkClmp))) * math.div(1, map.get($SA98G, mFactor)) - map.get($SA98G, mOffsetOut);
122 }
123
124 $unknownY: math.max(math.min($unknownY, 1), 0);
125
126 @return $unknownY;
127}
diff --git a/src/functions/colors/_index.scss b/src/functions/colors/_index.scss
deleted file mode 100644
index 9dad0f9..0000000
--- a/src/functions/colors/_index.scss
+++ /dev/null
@@ -1 +0,0 @@
1@forward 'apca';