From 0adc2b7014d9909869bc9888ac90a3ec142d9488 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Tue, 8 Oct 2024 12:36:57 +0200 Subject: Replace Oddbird with native SASS color functions --- src/functions/colors/_apca.scss | 54 ++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'src/functions/colors/_apca.scss') 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 @@ $SA98G: ( mainTRC: 2.4, - sRco: 0.2126729, - sGco: 0.7151522, - sBco: 0.0721750, + sRco: .2126729, + sGco: .7151522, + sBco: .072175, - normBG: 0.56, - normTXT: 0.57, - revTXT: 0.62, - revBG: 0.65, + normBG: .56, + normTXT: .57, + revTXT: .62, + revBG: .65, - blkThrs: 0.022, + blkThrs: .022, blkClmp: 1.414, scaleBoW: 1.14, scaleWoB: 1.14, - loBoWoffset: 0.027, - loWoBoffset: 0.027, - deltaYmin: 0.0005, - loClip: 0.0001, - - mFactor: 1.94685544331710, - mOffsetIn: 0.03873938165714010, - mExpAdj: 0.2833433964208690, - mOffsetOut: 0.3128657958707580, + loBoWoffset: .027, + loWoBoffset: .027, + deltaYmin: .0005, + loClip: .0001, + + mFactor: 1.9468554433171, + mOffsetIn: .0387393816571401, + mExpAdj: .283343396420869, + mOffsetOut: .312865795870758, ); @function apca_sRGB_to_Y($color) { - @return map.get($SA98G, sRco) * math.pow(math.div(color.red($color), 255), map.get($SA98G, mainTRC)) + - map.get($SA98G, sGco) * math.pow(math.div(color.green($color), 255), map.get($SA98G, mainTRC)) + - map.get($SA98G, sBco) * math.pow(math.div(color.blue($color), 255), map.get($SA98G, mainTRC)); + $rgb: color.to-space($color, rgb); + + @return map.get($SA98G, sRco) * math.pow(math.div(color.channel($rgb, 'red'), 255), map.get($SA98G, mainTRC)) + + map.get($SA98G, sGco) * math.pow(math.div(color.channel($rgb, 'green'), 255), map.get($SA98G, mainTRC)) + + map.get($SA98G, sBco) * math.pow(math.div(color.channel($rgb, 'blue'), 255), map.get($SA98G, mainTRC)); } @function apca_Y_to_sRGB($y) { @@ -45,7 +47,7 @@ $SA98G: ( } @function apcaContrast($txtY, $bgY) { - $icp: 0.0 1.1; + $icp: 1.1; @if math.min($txtY, $bgY) < list.nth($icp, 1) or math.max($txtY, $bgY) > list.nth($icp, 2) { @return 0; @@ -78,7 +80,7 @@ $SA98G: ( } } - @return $outputContrast * 100.0; + @return $outputContrast * 100; } @function apcaReverse($contrast, $knownY, $knownType: 'bg') { @@ -90,7 +92,7 @@ $SA98G: ( $scale: map.get($SA98G, if($contrast > 0, scaleBoW, scaleWoB)); $offset: map.get($SA98G, if($contrast > 0, loBoWoffset, loWoBoffset)); - $contrast: math.div($contrast * 0.01 + $offset, $scale); + $contrast: math.div($contrast * .01 + $offset, $scale); @if $knownY <= map.get($SA98G, blkThrs) { $knownY: $knownY + math.pow(map.get($SA98G, blkThrs) - $knownY, map.get($SA98G, blkClmp)); @@ -115,10 +117,8 @@ $SA98G: ( } @if $unknownY <= map.get($SA98G, blkThrs) { - $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); + $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); } $unknownY: math.max(math.min($unknownY, 1), 0); -- cgit v1.3.1