densifyGlassSurface function
The display backing surface made denser (alpha + 10 at a time) until
a text of text's polarity reaches the display and preview floors
(+ 0.15) on it composited over every background sample.
Implementation
int densifyGlassSurface(
int surface,
int text,
GuardrailLimits lim,
List<int> bgs,
) {
final preview = lim.previewRatio < ratioText ? ratioText : lim.previewRatio;
final target =
(lim.displayRatio > preview ? lim.displayRatio : preview) + 0.15;
var a = (surface >>> 24) & 0xFF;
final light =
luminanceArgb(text | 0xFF000000) > luminanceArgb(surface | 0xFF000000);
while (a < 255) {
final panels = faceSamples(withAlpha(surface, a), bgs);
final probe = solveOnAll(text | 0xFF000000, panels, target);
if (probe != null && _keepsPolarity(probe, panels, light: light)) break;
a = a + 10 > 255 ? 255 : a + 10;
}
return withAlpha(surface, a);
}