diff options
Diffstat (limited to 'src/functions/colors/_apca.scss')
| -rw-r--r-- | src/functions/colors/_apca.scss | 127 | 
1 files changed, 0 insertions, 127 deletions
| diff --git a/src/functions/colors/_apca.scss b/src/functions/colors/_apca.scss deleted file mode 100644 index d9236b2..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: 0.2126729, | ||
| 13 | sGco: 0.7151522, | ||
| 14 | sBco: 0.0721750, | ||
| 15 | |||
| 16 | normBG: 0.56, | ||
| 17 | normTXT: 0.57, | ||
| 18 | revTXT: 0.62, | ||
| 19 | revBG: 0.65, | ||
| 20 | |||
| 21 | blkThrs: 0.022, | ||
| 22 | blkClmp: 1.414, | ||
| 23 | scaleBoW: 1.14, | ||
| 24 | scaleWoB: 1.14, | ||
| 25 | loBoWoffset: 0.027, | ||
| 26 | loWoBoffset: 0.027, | ||
| 27 | deltaYmin: 0.0005, | ||
| 28 | loClip: 0.0001, | ||
| 29 | |||
| 30 | mFactor: 1.94685544331710, | ||
| 31 | mOffsetIn: 0.03873938165714010, | ||
| 32 | mExpAdj: 0.2833433964208690, | ||
| 33 | mOffsetOut: 0.3128657958707580, | ||
| 34 | ); | ||
| 35 | |||
| 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)) + | ||
| 38 | map.get($SA98G, sGco) * math.pow(math.div(color.green($color), 255), map.get($SA98G, mainTRC)) + | ||
| 39 | map.get($SA98G, sBco) * math.pow(math.div(color.blue($color), 255), map.get($SA98G, mainTRC)); | ||
| 40 | } | ||
| 41 | |||
| 42 | @function apca_Y_to_sRGB($y) { | ||
| 43 | $c: math.round(math.pow($y, math.div(1, map.get($SA98G, mainTRC))) * 255); | ||
| 44 | @return rgb($c, $c, $c); | ||
| 45 | } | ||
| 46 | |||
| 47 | @function apcaContrast($txtY, $bgY) { | ||
| 48 | $icp: 0.0 1.1; | ||
| 49 | |||
| 50 | @if math.min($txtY, $bgY) < list.nth($icp, 1) or math.max($txtY, $bgY) > list.nth($icp, 2) { | ||
| 51 | @return 0; | ||
| 52 | } | ||
| 53 | |||
| 54 | @if $txtY <= map.get($SA98G, blkThrs) { | ||
| 55 | $txtY: $txtY + math.pow(map.get($SA98G, blkThrs) - $txtY, map.get($SA98G, blkClmp)); | ||
| 56 | } | ||
| 57 | @if $bgY <= map.get($SA98G, blkThrs) { | ||
| 58 | $bgY: $bgY + math.pow(map.get($SA98G, blkThrs) - $bgY, map.get($SA98G, blkClmp)); | ||
| 59 | } | ||
| 60 | |||
| 61 | @if math.abs($bgY - $txtY) < map.get($SA98G, deltaYmin) { | ||
| 62 | @return 0; | ||
| 63 | } | ||
| 64 | |||
| 65 | $outputContrast: 0; | ||
| 66 | |||
| 67 | @if $bgY > $txtY { | ||
| 68 | $SAPC: map.get($SA98G, scaleBoW) * (math.pow($bgY, map.get($SA98G, normBG)) - math.pow($txtY, map.get($SA98G, normTXT))); | ||
| 69 | |||
| 70 | @if $SAPC >= map.get($SA98G, loClip) { | ||
| 71 | $outputContrast: $SAPC - map.get($SA98G, loBoWoffset); | ||
| 72 | } | ||
| 73 | } @else { | ||
| 74 | $SAPC: map.get($SA98G, scaleWoB) * (math.pow($bgY, map.get($SA98G, revBG)) - math.pow($txtY, map.get($SA98G, revTXT))); | ||
| 75 | |||
| 76 | @if $SAPC <= -1 * map.get($SA98G, loClip) { | ||
| 77 | $outputContrast: $SAPC + map.get($SA98G, loWoBoffset); | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | @return $outputContrast * 100.0; | ||
| 82 | } | ||
| 83 | |||
| 84 | @function apcaReverse($contrast, $knownY, $knownType: 'bg') { | ||
| 85 | $unknownY: $knownY; | ||
| 86 | |||
| 87 | $knownExp: 0; | ||
| 88 | $unknownExp: 0; | ||
| 89 | |||
| 90 | $scale: map.get($SA98G, if($contrast > 0, scaleBoW, scaleWoB)); | ||
| 91 | $offset: map.get($SA98G, if($contrast > 0, loBoWoffset, loWoBoffset)); | ||
| 92 | |||
| 93 | $contrast: math.div($contrast * 0.01 + $offset, $scale); | ||
| 94 | |||
| 95 | @if $knownY <= map.get($SA98G, blkThrs) { | ||
| 96 | $knownY: $knownY + math.pow(map.get($SA98G, blkThrs) - $knownY, map.get($SA98G, blkClmp)); | ||
| 97 | } | ||
| 98 | |||
| 99 | @if $knownType == 'bg' { | ||
| 100 | $knownExp: map.get($SA98G, if($contrast > 0, normBG, revBG)); | ||
| 101 | $unknownExp: map.get($SA98G, if($contrast > 0, normTXT, revTXT)); | ||
| 102 | $unknownY: math.pow(math.pow($knownY, $knownExp) - $contrast, math.div(1, $unknownExp)); | ||
| 103 | } @else { | ||
| 104 | $knownExp: map.get($SA98G, if($contrast > 0, normTXT, revTXT)); | ||
| 105 | $unknownExp: map.get($SA98G, if($contrast > 0, normBG, revBG)); | ||
| 106 | $unknownY: math.pow($contrast + math.pow($knownY, $knownExp), math.div(1, $unknownExp)); | ||
| 107 | } | ||
| 108 | |||
| 109 | @if '#{$unknownY}' == '#{math.sqrt(-1)}' { | ||
| 110 | @return false; | ||
| 111 | } | ||
| 112 | |||
| 113 | @if $unknownY > 1.06 or $unknownY < 0 { | ||
| 114 | @return false; | ||
| 115 | } | ||
| 116 | |||
| 117 | @if $unknownY <= map.get($SA98G, blkThrs) { | ||
| 118 | $unknownY: math.pow( | ||
| 119 | ($unknownY + map.get($SA98G, mOffsetIn)) * map.get($SA98G, mFactor), | ||
| 120 | math.div(map.get($SA98G, mExpAdj), map.get($SA98G, blkClmp)) | ||
| 121 | ) * 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 | } | ||
