boltStrokeWith function

void boltStrokeWith(
  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,
  11. double? upTo,
})

Implementation

void boltStrokeWith(
  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,
  double? upTo,
}) {
  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 = upTo != null && trunk
        ? q.pts.sublist(
            0,
            math.min(q.pts.length, math.max(2, (q.pts.length * upTo).ceil())),
          )
        : q.pts;
    _walk(pts, (x, y, _) {
      _stampBolt(x, y, rh, 1);
      _stampBolt(x, y, rb, trunk ? 3 : 2);
      if (trunk && k > 0.3) {
        if (core > 0.0) {
          _stampBolt(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],
  );
}