decodePoint method

List<List<int>> decodePoint()

Implementation

List<List<int>> decodePoint() {
  int length = 0;
  int commandId = 0;
  int x = 0;
  int y = 0;
  bool isX = true;
  List<List<int>> coords = [];
  List<int> point = [];

  this.geometryList!.forEach((commandInt) {
    if (length <= 0) {
      Command command = Command.CommandInteger(command: commandInt);

      commandId = command.id;
      length = command.count;
    } else if (commandId != CommandID.ClosePath) {
      if (isX) {
        x += Command.zigZagDecode(commandInt);
        point.add(x);
        isX = false;
      } else {
        y += Command.zigZagDecode(commandInt);
        point.add(y);
        length -= 1;
        isX = true;
      }
    }

    if (length <= 0) {
      coords.add(point);
      point = [];
    }
  });

  return coords;
}