tintActor function
Flash a character in light: pixels recolored by brightness into ramp.
Implementation
void tintActor(Painter p, ActorDefinition? a, double k, List<int> ramp) {
if (a == null || k <= 0.12) return;
final m = a.mask;
final pix = a.pixels;
final cut = k > 0.6 ? 0.0 : (k > 0.3 ? 0.22 : 0.5);
for (var j = 0; j < m.h; j++) {
for (var i = 0; i < m.w; i++) {
final q = j * m.w + i;
if (m.data[q] == 0) continue;
final l = luma(pix[q]);
if (l < cut) continue;
p.px(
a.x + i,
a.y + j,
l > 0.5
? (k > 0.8 ? kWhite : ramp[2])
: (l > 0.22 ? ramp[1] : ramp[0]),
);
}
}
}