repairKeyLabel function
Re-solves k's label on its (opaque) face to policy; moves the face
as well when the label alone cannot reach it. Null for translucent
faces that fail.
Implementation
KeyColors? repairKeyLabel(
KeyColors k,
ContrastPolicy policy,
List<int> backgrounds,
) {
if (_minContrast(k.label, faceSamples(k.face, backgrounds)) >=
policy.minRatio) {
return k;
}
if (((k.face >>> 24) & 0xFF) != 255) return null;
final labelLch = argbToOklch(k.label);
final solved = solveLabel(k.face, labelLch, policy: policy);
if (solved != null) return k.copyWith(label: solved);
final pair = repairPair(argbToOklch(k.face), labelLch, policy: policy);
return k.copyWith(face: pair.face, label: pair.label);
}