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