darkerBackgroundApcaY function

double darkerBackgroundApcaY(
  1. double textApcaY,
  2. double apca, {
  3. bool debug = false,
})

Implementation

double darkerBackgroundApcaY(
  double textApcaY,
  double apca, {
  bool debug = false,
}) {
  textApcaY = inBoundsApcaY(textApcaY);
  apca = apca / 100.0;
  if (apca > 0) {
    apca = -apca;
  }
  // Go backwards through apcaContrastOfApcaY with background < text
  final sapc = apca == 0.0 ? 0.0 : apca - loWoBOffset;
  // k1 = revBg
  // k2 = revText
  // k3 = scaleWoB
  // x = sapc
  // y = backgroundApcaY
  // z = textApcaY

  // Find Y:
  // sapc = (backgroundApcaY ^ revBg - textApcaY ^ revText) * scaleWoB
  // x = (y^k1 - z^k2) * k3
  // x / k3 = y ^ k1 - z ^k2
  // x / k3 + z ^ k2 = y ^ k1
  // y ^ k1 = x / k3 + z ^ k2
  // y = (x / k3 + z ^ k2) ^ (1/k1)
  final firstTerm = sapc / scaleWoB;
  final secondTerm = math.pow(textApcaY, revText);
  final base = firstTerm + secondTerm;
  if (base < 0) {
    final complex = Complex(0, (secondTerm + firstTerm)).pow(1 / revBg);
    monetDebug(debug, () => 'darkerBackgroundApcaY complex: $complex');
    return complex.real;
  }
  final bgApcaY = math.pow(base, 1.0 / revBg).toDouble();
  return bgApcaY;
}