dotsOnLines method

OpSet dotsOnLines(
  1. List<Line> lines,
  2. FillerConfig config
)

Implementation

OpSet dotsOnLines(List<Line> lines, FillerConfig config) {
  List<Op> ops = [];
  final double gap = max(config.hachureGap, 0.1);
  final double fWeight = max(config.fillWeight, 0.1);
  final double ro = gap / 4;
  for (Line line in lines) {
    final double length = line.length;
    final double dl = length / gap;
    final int count = dl.ceil() - 1;
    final double off = length - (count * gap);
    final double x = ((line.source.x + line.target.x) / 2) - (gap / 4);
    final double minY = min(line.source.y, line.target.y);
    for (int i = 0; i < count; i++) {
      double y = minY + off + (i * gap);
      double cx = config.drawConfig.offset(x - ro, x + ro);
      double cy = config.drawConfig.offset(y - ro, y + ro);
      OpSet el =
          OpSetBuilder.ellipse(cx, cy, fWeight, fWeight, config.drawConfig);
      ops.addAll(el.ops);
    }
  }
  return OpSet(type: OpSetType.fillSketch, ops: ops);
}