scrimFor method

Scrim scrimFor(
  1. int contentArgb, {
  2. Usage usage = Usage.text,
  3. int? scrimArgb,
})

The minimum-opacity scrim that makes contentArgb meet usage's contrast against every pixel, and keeps meeting it at every opacity above, so callers may round up freely.

scrimArgb fixes the scrim color, e.g. brand-tinted; null tries black and white and returns the cheaper. A fixed color can be infeasible: at opacity 1 the background is the scrim color itself.

Implementation

Scrim scrimFor(int contentArgb, {Usage usage = Usage.text, int? scrimArgb}) {
  return _scrims.putIfAbsent((
    contentArgb,
    usage,
    scrimArgb,
  ), () => _solveScrim(contentArgb, usage, scrimArgb));
}