placements property

Map<String, Duration> get placements

Where each placed group starts, by name. A group placed twice keeps its first placement; a speed scales nothing here yet, so a group inside one is drawn at its unscaled offset.

Implementation

Map<String, Duration> get placements {
  var out = <String, Duration>{};
  void visit(TimelineExpr e, Duration at) {
    switch (e) {
      case AnimateGroup g:
        out.putIfAbsent(g.name, () => at);
      case ParExpr p:
        for (var c in p.children) {
          visit(c, at);
        }
      case SeqExpr s:
        var t = at;
        for (var c in s.children) {
          visit(c, t);
          t += durationOf(c);
        }
      case AtExpr a:
        visit(a.child, at + a.offset);
      case SpeedExpr s:
        visit(s.child, at);
      case RepeatExpr r:
        visit(r.child, at);
    }
  }

  visit(timeline, Duration.zero);
  return out;
}