exploded method

List<SPath> exploded({
  1. double magnitude = 1.2,
  2. double scale = 1,
})

Segment then explode outwards and scale

Implementation

List<SPath> exploded({double magnitude = 1.2, double scale = 1}) {
  if (edges.length < 2) {
    throw Exception("You must have at least two edges to segment a (S)Path");
  }
  final c = centroid;
  final n = edges.length;
  List<SPath> paths = [];
  for (var i = 0; i < n; i++) {
    var p = SPath(edges[i].start);
    p.edges.add(edges[i].copy());
    p.currentPoint = edges[i].end;
    p.line(to: c);
    p.close();
    p = p.scaled(scale);
    // local centroid minus global is relative direction; multiply by magnitude - 1 to get the displacement to apply
    p = p.moved((p.centroid - centroid) * (magnitude - 1.0));
    paths.add(p);
  }
  return paths;
}