plus function
void
plus(])
A plus sign of light centred on (x, y): arm length armLen (1..4) and thickness th (1 or 3).
Implementation
void plus(
Painter p,
double x,
double y,
int armLen,
int th,
List<int> rampColors, [
double a = 1.0,
bool glint = false,
]) {
final n = rampColors.length;
final xi = holyRound(x);
final yi = holyRound(y);
final w = th > 1 ? 1 : 0;
bool ins(int i, int j) =>
(i.abs() <= w && j.abs() <= armLen) ||
(j.abs() <= w && i.abs() <= armLen);
for (var j = -armLen - 1; j <= armLen + 1; j++) {
for (var i = -armLen - 1; i <= armLen + 1; i++) {
if (!ins(i, j)) {
if (w != 0 &&
(ins(i - 1, j) ||
ins(i + 1, j) ||
ins(i, j - 1) ||
ins(i, j + 1))) {
p.dot(xi + i, yi + j, rampColors[math.max(0, n - 6)], a * 0.9);
}
continue;
}
int c;
if (w == 0) {
c = i == 0 && j == 0
? kWhite
: (i.abs() + j.abs() >= armLen
? rampColors[n - 3]
: rampColors[n - 2]);
} else if (i == 0 && j == 0) {
c = kWhite;
} else if (i == 0 || j == 0) {
c = i.abs() + j.abs() < armLen
? rampColors[n - 2]
: rampColors[n - 3];
} else {
c = i < 0 || j < 0 ? rampColors[n - 3] : rampColors[n - 5];
}
if (glint && ((i == 0 && j == -armLen) || (i == -armLen && j == 0))) {
c = kWhite;
}
p.dot(xi + i, yi + j, c, a);
}
}
}