y2kEdgeSamples function

List<int> y2kEdgeSamples(
  1. List<int> bgs,
  2. int shadow
)

What a key rim or the focus ring is seen against: the scene samples bgs, plain and under the keys' own shadow (y2kEdgeShadowAlpha).

Implementation

List<int> y2kEdgeSamples(List<int> bgs, int shadow) {
  final key = (bgs, shadow);
  final hit = _edgeMemo.remove(key);
  if (hit != null) return _edgeMemo[key] = hit;
  final s = withAlpha(shadow, y2kEdgeShadowAlpha(shadow));
  final list = List<int>.unmodifiable([
    ...bgs,
    for (final b in bgs) compositeOver(s, b),
  ]);
  _edgeMemo[key] = list;
  while (_edgeMemo.length > 8) {
    _edgeMemo.remove(_edgeMemo.keys.first);
  }
  return list;
}