durationOf method

Duration durationOf(
  1. TimelineExpr expr
)

How long expr runs. A group placed here is the group, so there is nothing to resolve and nothing that can dangle.

Implementation

Duration durationOf(TimelineExpr expr) => switch (expr) {
  AnimateGroup g => g.duration,
  ParExpr p => p.children.fold(
    Duration.zero,
    (m, c) => durationOf(c) > m ? durationOf(c) : m,
  ),
  SeqExpr s => s.children.fold(Duration.zero, (m, c) => m + durationOf(c)),
  AtExpr a => a.offset + durationOf(a.child),
  SpeedExpr s => Duration(
    microseconds: (durationOf(s.child).inMicroseconds / s.factor).round(),
  ),
  RepeatExpr r => durationOf(r.child) * r.times,
};