solveLabel function
Solves a label (start colour label) on the opaque face faceArgb
under policy: dark-face boost, then the polarity rule, then the plain
floor. Returns null only if even the floor is unreachable at this
chroma/hue (possible above 4.583:1).
Implementation
int? solveLabel(
int faceArgb,
Lch label, {
ContrastPolicy policy = ContrastPolicy.standard,
}) {
final faceY = luminanceArgb(faceArgb);
final target = policy.targetFor(faceY);
if (policy.inPolarityBand(faceY)) {
final faceL = argbToOklab(faceArgb).$1;
final light = solveLightness(
l0: label.l,
c: label.c,
hDeg: label.h,
againstArgb: faceArgb,
target: policy.minRatio,
preferLighter: true,
lighterFrom: label.l > faceL ? label.l : faceL,
);
if (light != null && luminanceArgb(light) > faceY) return light;
}
final boosted = solveLightness(
l0: label.l,
c: label.c,
hDeg: label.h,
againstArgb: faceArgb,
target: target,
);
if (boosted != null || target <= policy.minRatio) return boosted;
return solveLightness(
l0: label.l,
c: label.c,
hDeg: label.h,
againstArgb: faceArgb,
target: policy.minRatio,
);
}