pillow function
void
pillow(})
Implementation
void pillow(
SpriteLayer l,
double x0,
double y0,
double x1,
double y1,
double Function(double x, double y) sdf,
int Function(double b, double e, double x, double y) color, {
double bevel = 3.0,
List<double> light = const [-0.5, -0.6, 0.62],
bool Function(double x, double y)? clip,
}) {
l.fill(x0, y0, x1, y1, (x, y) {
final d = sdf(x, y);
if (d > 0.0 || (clip != null && clip(x, y))) return 0;
final e = -d;
var gx = sdf(x + 0.5, y) - sdf(x - 0.5, y);
var gy = sdf(x, y + 0.5) - sdf(x, y - 0.5);
final glRaw = hypot(gx, gy);
final gl = glRaw == 0.0 ? 1.0 : glRaw;
gx /= gl;
gy /= gl;
final k = math.max(0.0, 1.0 - e / bevel) * 1.25;
final sn = math.sin(k);
final cs = math.cos(k);
return color(gx * sn * light[0] + gy * sn * light[1] + cs * light[2], e, x, y);
});
}