icon function
void
icon(])
A little shaded pixel icon at (x, y) filled from r = outline, shadow, body, light.
Implementation
void icon(
Painter p,
num x,
num y,
int ext,
IconMask inside,
List<int> r, [
double a = 1.0,
Map<String, int>? paint,
]) {
final bigX = (x + 0.5).floor();
final bigY = (y + 0.5).floor();
bool at(int dx, int dy) => inside(dx, dy).isNotEmpty;
for (var dy = -ext - 1; dy <= ext + 1; dy++) {
for (var dx = -ext - 1; dx <= ext + 1; dx++) {
final ch = inside(dx, dy);
int c;
if (ch.isNotEmpty) {
final mapped = paint?[ch];
if (mapped != null) {
c = mapped;
} else {
final top = !at(dx, dy - 1);
final left = !at(dx - 1, dy);
final bottom = !at(dx, dy + 1);
final right = !at(dx + 1, dy);
c = top || left ? r[3] : (bottom || right ? r[1] : r[2]);
}
} else if (r[0] != 0 &&
(at(dx - 1, dy) ||
at(dx + 1, dy) ||
at(dx, dy - 1) ||
at(dx, dy + 1))) {
c = r[0];
} else {
continue;
}
p.dot(bigX + dx, bigY + dy, c, a);
}
}
}