darkerTextApcaY function
Implementation
double darkerTextApcaY(
double backgroundApcaY,
double apca, {
bool debug = false,
}) {
backgroundApcaY = inBoundsApcaY(backgroundApcaY);
monetDebug(debug, () => 'backgroundApcaY: $backgroundApcaY');
apca = apca / 100.0;
monetDebug(debug, () => 'apca: $apca');
// Go backwards through apcaContrastOfApcaY with background > text
final sapc = apca == 0.0 ? 0.0 : apca + loBoWOffset;
// k1 = normBg
// k2 = normText
// k3 = scaleBoW
// x = sapc
// y = backgroundApcaY
// z = textApcaY
// Find Z:
// sapc = (backgroundApcaY ^ normBg - textApcaY ^ normText) * scaleBow
// x = (y^k1 - z^k2) * k3
// x / k3 = y ^ k1 - z ^k2
// x / k3 + z ^ k2 = y ^ k1
// z ^ k2 = (y ^ k1 - x / k3)
// z = ((y ^ k1) - (x / k3)) ^ (1/k2)
final firstTerm = math.pow(backgroundApcaY, normBg);
final secondTerm = sapc / scaleBoW;
final base = firstTerm - secondTerm;
if (base < 0) {
// When 'secondTerm' is greater than 'firstTerm', the difference
// (firstTerm - secondTerm) is negative.
// Negative numbers present complexities when raised to fractional powers.
// To adhere to mathematical principals in the complex plane,
// we switch positions from 'firstTerm - secondTerm' to 'secondTerm - firstTerm'
// to make the difference positive.
// As we are dealing with a negative number (in the real number system),
// which corresponds to a purely imaginary number in the complex plane,
// we put this positive difference in the imaginary part (0, (secondTerm - firstTerm).abs()).
// This way, we represent the original negative real number as a positive imaginary number,
// in order to handle the power operation in the complex number system properly.
Complex complexTerm2 = Complex(
0,
(secondTerm - firstTerm),
).pow(1 / normText);
return complexTerm2.real;
}
final textApcaY = math.pow(base, 1.0 / normText).toDouble();
return textApcaY;
}