summaryrefslogtreecommitdiffstats
path: root/src/functions/colors/_apca.scss
diff options
context:
space:
mode:
Diffstat (limited to 'src/functions/colors/_apca.scss')
-rw-r--r--src/functions/colors/_apca.scss52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/functions/colors/_apca.scss b/src/functions/colors/_apca.scss
index d9236b2..c848db7 100644
--- a/src/functions/colors/_apca.scss
+++ b/src/functions/colors/_apca.scss
@@ -9,34 +9,36 @@
9$SA98G: ( 9$SA98G: (
10 mainTRC: 2.4, 10 mainTRC: 2.4,
11 11
12 sRco: 0.2126729, 12 sRco: .2126729,
13 sGco: 0.7151522, 13 sGco: .7151522,
14 sBco: 0.0721750, 14 sBco: .072175,
15 15
16 normBG: 0.56, 16 normBG: .56,
17 normTXT: 0.57, 17 normTXT: .57,
18 revTXT: 0.62, 18 revTXT: .62,
19 revBG: 0.65, 19 revBG: .65,
20 20
21 blkThrs: 0.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: 0.027, 25 loBoWoffset: .027,
26 loWoBoffset: 0.027, 26 loWoBoffset: .027,
27 deltaYmin: 0.0005, 27 deltaYmin: .0005,
28 loClip: 0.0001, 28 loClip: .0001,
29 29
30 mFactor: 1.94685544331710, 30 mFactor: 1.9468554433171,
31 mOffsetIn: 0.03873938165714010, 31 mOffsetIn: .0387393816571401,
32 mExpAdj: 0.2833433964208690, 32 mExpAdj: .283343396420869,
33 mOffsetOut: 0.3128657958707580, 33 mOffsetOut: .312865795870758,
34); 34);
35 35
36@function apca_sRGB_to_Y($color) { 36@function apca_sRGB_to_Y($color) {
37 @return map.get($SA98G, sRco) * math.pow(math.div(color.red($color), 255), map.get($SA98G, mainTRC)) + 37 $rgb: color.to-space($color, rgb);
38 map.get($SA98G, sGco) * math.pow(math.div(color.green($color), 255), map.get($SA98G, mainTRC)) + 38
39 map.get($SA98G, sBco) * math.pow(math.div(color.blue($color), 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)) +
41 map.get($SA98G, sBco) * math.pow(math.div(color.channel($rgb, 'blue'), 255), map.get($SA98G, mainTRC));
40} 42}
41 43
42@function apca_Y_to_sRGB($y) { 44@function apca_Y_to_sRGB($y) {
@@ -45,7 +47,7 @@ $SA98G: (
45} 47}
46 48
47@function apcaContrast($txtY, $bgY) { 49@function apcaContrast($txtY, $bgY) {
48 $icp: 0.0 1.1; 50 $icp: 1.1;
49 51
50 @if math.min($txtY, $bgY) < list.nth($icp, 1) or math.max($txtY, $bgY) > list.nth($icp, 2) { 52 @if math.min($txtY, $bgY) < list.nth($icp, 1) or math.max($txtY, $bgY) > list.nth($icp, 2) {
51 @return 0; 53 @return 0;
@@ -78,7 +80,7 @@ $SA98G: (
78 } 80 }
79 } 81 }
80 82
81 @return $outputContrast * 100.0; 83 @return $outputContrast * 100;
82} 84}
83 85
84@function apcaReverse($contrast, $knownY, $knownType: 'bg') { 86@function apcaReverse($contrast, $knownY, $knownType: 'bg') {
@@ -90,7 +92,7 @@ $SA98G: (
90 $scale: map.get($SA98G, if($contrast > 0, scaleBoW, scaleWoB)); 92 $scale: map.get($SA98G, if($contrast > 0, scaleBoW, scaleWoB));
91 $offset: map.get($SA98G, if($contrast > 0, loBoWoffset, loWoBoffset)); 93 $offset: map.get($SA98G, if($contrast > 0, loBoWoffset, loWoBoffset));
92 94
93 $contrast: math.div($contrast * 0.01 + $offset, $scale); 95 $contrast: math.div($contrast * .01 + $offset, $scale);
94 96
95 @if $knownY <= map.get($SA98G, blkThrs) { 97 @if $knownY <= map.get($SA98G, blkThrs) {
96 $knownY: $knownY + math.pow(map.get($SA98G, blkThrs) - $knownY, map.get($SA98G, blkClmp)); 98 $knownY: $knownY + math.pow(map.get($SA98G, blkThrs) - $knownY, map.get($SA98G, blkClmp));
@@ -115,10 +117,8 @@ $SA98G: (
115 } 117 }
116 118
117 @if $unknownY <= map.get($SA98G, blkThrs) { 119 @if $unknownY <= map.get($SA98G, blkThrs) {
118 $unknownY: math.pow( 120 $unknownY: math.pow(($unknownY + map.get($SA98G, mOffsetIn)) * map.get($SA98G, mFactor),
119 ($unknownY + map.get($SA98G, mOffsetIn)) * map.get($SA98G, mFactor), 121 math.div(map.get($SA98G, mExpAdj), map.get($SA98G, blkClmp))) * math.div(1, map.get($SA98G, mFactor)) - map.get($SA98G, mOffsetOut);
120 math.div(map.get($SA98G, mExpAdj), map.get($SA98G, blkClmp))
121 ) * 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);