moveNext method

bool moveNext()

Implementation

bool moveNext() {
  if (_segmentIndex >= _path.segmentCount) return false;
  final direct = _path._segments;
  if (direct != null) {
    final segment = direct[_segmentIndex++];
    switch (segment) {
      case PdfMoveTo(:final x, :final y):
        verb = PdfPathVerb.moveTo;
        x1 = x;
        y1 = y;
      case PdfLineTo(:final x, :final y):
        verb = PdfPathVerb.lineTo;
        x1 = x;
        y1 = y;
      case PdfCubicTo(
          :final x1,
          :final y1,
          :final x2,
          :final y2,
          :final x3,
          :final y3
        ):
        verb = PdfPathVerb.cubicTo;
        this.x1 = x1;
        this.y1 = y1;
        this.x2 = x2;
        this.y2 = y2;
        this.x3 = x3;
        this.y3 = y3;
      case PdfClosePath():
        verb = PdfPathVerb.close;
    }
    return true;
  }

  final tag = _path._verbs![_segmentIndex++];
  final coordinates = _path._coordinates!;
  switch (tag) {
    case _moveTag:
      verb = PdfPathVerb.moveTo;
      x1 = coordinates[_coordinateIndex++];
      y1 = coordinates[_coordinateIndex++];
    case _lineTag:
      verb = PdfPathVerb.lineTo;
      x1 = coordinates[_coordinateIndex++];
      y1 = coordinates[_coordinateIndex++];
    case _cubicTag:
      verb = PdfPathVerb.cubicTo;
      x1 = coordinates[_coordinateIndex++];
      y1 = coordinates[_coordinateIndex++];
      x2 = coordinates[_coordinateIndex++];
      y2 = coordinates[_coordinateIndex++];
      x3 = coordinates[_coordinateIndex++];
      y3 = coordinates[_coordinateIndex++];
    case _closeTag:
      verb = PdfPathVerb.close;
    default:
      throw StateError('invalid packed path verb $tag');
  }
  return true;
}