panel function

void panel(
  1. Painter p,
  2. double x,
  3. double y,
  4. double w,
  5. double h,
  6. PanelColors col, {
  7. double r = 3.0,
  8. double a = 1.0,
  9. double? shine,
})

Implementation

void panel(
  Painter p,
  double x,
  double y,
  double w,
  double h,
  PanelColors col, {
  double r = 3.0,
  double a = 1.0,
  double? shine,
}) {
  if (w < 2.0 || h < 2.0) return;
  final x1 = x + w;
  final y1 = y + h;
  p.shade(x, y, x1, y1, (px, py, out) {
    final cx = math.max(x + r - px, math.max(0.0, px - (x1 - r)));
    final cy = math.max(y + r - py, math.max(0.0, py - (y1 - r)));
    final e = (cx > 0.0 && cy > 0.0)
        ? r - hypot(cx, cy)
        : math.min(math.min(px - x, x1 - px), math.min(py - y, y1 - py));
    if (e < 0.0) return null;
    out.a = a;
    if (e < 1.0) return col.outline;
    if (py - y < 2.0) return col.rim;
    if (y1 - py < 2.0) return col.low;
    if (shine != null) {
      final d = (px - (py - y) * 0.6 - shine).abs();
      if (d < 1.3) return kWhite;
      if (d < 3.0) return col.rim;
    }
    return py - y < h * 0.45 ? col.top : col.body;
  });
}