boltStroke function

void boltStroke(
  1. Painter p,
  2. BoltTree b,
  3. double k,
  4. List<int> c, [
  5. double s = 1.0,
  6. bool hero = false,
  7. double light = 0.5,
  8. double a = 1.0,
  9. double core = 0.0,
  10. double? minY,
])

Implementation

void boltStroke(
  Painter p,
  BoltTree b,
  double k,
  List<int> c, [
  double s = 1.0,
  bool hero = false,
  double light = 0.5,
  double a = 1.0,
  double core = 0.0,
  double? minY,
]) {
  if (k <= 0.02) return;
  for (final q in b.paths) {
    final trunk = q.w >= 1.0;
    if (!trunk && k < 0.5) continue;
    final rh = (trunk ? (k > 0.6 ? 2.1 : 1.6) : 1.1) * s;
    final rb = (trunk ? (k > 0.6 ? 1.3 : 0.8) : 0.5) * s;
    final pts = q.pts;
    _walk(pts, (x, y, _) {
      _inkGrid.stamp(x, y, rh, 1);
      _inkGrid.stamp(x, y, rb, trunk ? 3 : 2);
      if (trunk && k > 0.3) {
        if (core > 0.0) {
          _inkGrid.stamp(x, y, core, 4);
        } else {
          _inkGrid.mark(x, y, 4);
        }
      }
    });
    for (var i = 0; i < pts.length - 1; i += 3) {
      if (minY == null || pts[i].$2 > minY) {
        p.glow(pts[i].$1, pts[i].$2, (trunk ? 14.0 : 7.0) * s, c[4],
            light * k * q.w);
      }
    }
  }
  _inkGrid.flush(
    p,
    hero ? [c[3], c[6], c[7], c[7]] : [c[2], c[4], c[5], c[7]],
    [a, a, a, a],
  );
}