gemlet function
void
gemlet(})
Implementation
void gemlet(
SpriteLayer l,
Painter p,
double x,
double y,
double r,
double ang,
List<int> g, {
bool white = false,
double a = 1.0,
}) {
final xx = (x + 0.5).floor();
final yy = (y + 0.5).floor();
final ca = math.cos(ang);
final sa = math.sin(ang);
final n = g.length;
final rad = (r * 1.4).ceil() + 2;
final ct = r * 0.75;
final tw = r * 0.5;
final pv = r * 1.3;
l.begin(xx - rad, yy - rad);
l.fill(xx - rad, yy - rad, xx + rad - 1, yy + rad - 1, (px, py) {
final dx = px - xx;
final dy = py - yy;
final u = dx * ca + dy * sa;
final w = -dx * sa + dy * ca;
int facet;
if (w < 0.0) {
if (w < -ct || u.abs() > r - ((-w) / ct) * (r - tw)) return 0;
facet = w < -ct * 0.45 && u.abs() < tw * 0.95 ? 0 : (u < 0.0 ? 1 : 2);
} else {
if (w > pv || u.abs() > r * (1.0 - w / pv)) return 0;
facet = u.abs() < 0.5 ? 4 : (u < 0.0 ? 3 : 5);
}
if (white) return kWhite;
const normals = [
(0.0, -1.0),
(-0.7, -0.7),
(0.7, -0.7),
(-0.6, 0.8),
(0.0, 1.0),
(0.6, 0.8),
];
final norm = normals[facet];
final nx = norm.$1 * ca - norm.$2 * sa;
final ny = norm.$1 * sa + norm.$2 * ca;
final lit = -(nx * 0.62 + ny * 0.78);
if (facet == 0 && lit > 0.3 && u < 0.0) return kWhite;
return lit > 0.6
? g[n - 1]
: (lit > 0.2
? g[n - 2]
: (lit > -0.2 ? g[n - 3] : (lit > -0.6 ? g[n - 4] : g[n - 5])));
});
l.outline(g[0]).draw(p, 0, 0, a);
}