lighterTextLstar function
Implementation
double lighterTextLstar(
double backgroundLstar,
double apca, {
bool debug = false,
}) {
monetDebug(debug, () => 'LIGHTER TEXT L* ENTER');
final backgroundApcaY = lstarToApcaY(backgroundLstar);
monetDebug(debug, () => 'apcaY: $backgroundApcaY');
final lighterTextApcaYValue = lighterTextApcaY(
backgroundApcaY,
apca,
debug: debug,
);
if (lighterTextApcaYValue > 1.0) {
monetDebug(
debug,
() => 'lighter text has $lighterTextApcaYValue, lets check darker',
);
final darkerTextApcaYValue = darkerTextApcaY(
backgroundApcaY,
apca,
debug: debug,
);
if (darkerTextApcaYValue < 0) {
final distanceFromNeededLightToMaxLight = lighterTextApcaYValue - 1.0;
final distanceFromNeededDarkToMaxDark = 0.0 - darkerTextApcaYValue;
if (distanceFromNeededLightToMaxLight > distanceFromNeededDarkToMaxDark) {
monetDebug(
debug,
() =>
'going with darker, lighter distance was $distanceFromNeededLightToMaxLight, darker distance was $distanceFromNeededDarkToMaxDark',
);
return 0.0;
} else {
monetDebug(debug, () => 'going with lighter');
return 100.0;
}
} else {
monetDebug(
debug,
() =>
'asked for lighter, but darker is in bounds. darkerTextApcaYValue: $darkerTextApcaYValue',
);
return apcaYToLstarRange(darkerTextApcaYValue).darkest.clamp(0.0, 100.0);
}
}
return apcaYToLstarRange(lighterTextApcaYValue).lightest.clamp(0.0, 100.0);
}