getPieces method

Group getPieces(
  1. int numPieces
)

Implementation

Group getPieces(int numPieces) {
  var template = copy();
  template.submobjects = [];
  var alphas = linspace(start: 0, end: 1, count: numPieces + 1).flat();

  // alphas1 = alphas[:-1]
  var alphas1 =
      alphas.whereIndexed((index, element) => index != alphas.length - 1);
  // alphas2 = alphas[1:]
  var alphas2 = alphas.whereIndexed((index, element) => index != 0);

  return Group([
    for (var a in IterableZip([alphas1, alphas2]))
      template.copy()..pointwiseBecomePartial(this, a[0], a[1])
  ]);
}