From 9625f5c3dea3374a3beffab84b2785c0256796fa Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Wed, 23 Nov 2022 16:01:03 +0900 Subject: [PATCH] split out calcAPCAFromRGBA fn --- src/apca-w3.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/apca-w3.js b/src/apca-w3.js index 07b4451..4b6d321 100644 --- a/src/apca-w3.js +++ b/src/apca-w3.js @@ -432,13 +432,17 @@ export function calcAPCA (textColor, bgColor, places = -1, round = true) { // Note that this function requires colorParsley !! let bgClr = colorParsley(bgColor); let txClr = colorParsley(textColor); + return calcAPCAFromRGBA(txClr, bgClr, places, round); +} // End calcAPCA() + +////////// ƒ calcAPCAFromRGBA() ///////////////////////////////////////////// +export function calcAPCAFromRGBA (txClr, bgClr, places = -1, round = true) { let hasAlpha = (txClr[3] == '' || txClr[3] == 1) ? false : true ; if (hasAlpha) { txClr = alphaBlend( txClr, bgClr, round); }; return APCAcontrast( sRGBtoY(txClr), sRGBtoY(bgClr), places) -} // End calcAPCA() - +} // End calcAPCAFromRGBA()