CommandPathSource constructor

CommandPathSource(
  1. List<PathCmd> commands
)

Implementation

CommandPathSource(List<PathCmd> commands)
  : commands = List<PathCmd>.unmodifiable(commands) {
  var contourOpen = false;
  for (var index = 0; index < this.commands.length; index++) {
    final command = this.commands[index];
    if (command.verb == PathVerb.moveTo) {
      contourOpen = true;
    } else if (!contourOpen) {
      throw ArgumentError('commands[$index] requires a preceding moveTo.');
    }
    if (command.verb == PathVerb.close) {
      contourOpen = false;
      continue;
    }
    _requireFinite(command.p, 'commands[$index].p');
    if (command.c1 != null) {
      _requireFinite(command.c1!, 'commands[$index].c1');
    }
    if (command.c2 != null) {
      _requireFinite(command.c2!, 'commands[$index].c2');
    }
  }
}