GeoPathContext constructor

GeoPathContext(
  1. void moveTo(
    1. num,
    2. num
    ),
  2. void lineTo(
    1. num,
    2. num
    ),
  3. void arc(
    1. num,
    2. num,
    3. num,
    4. num,
    5. num,
    ),
  4. void closePath(), [
  5. Object? result() = noop,
])

Implementation

GeoPathContext(this.moveTo, this.lineTo, this.arc, this.closePath,
    [Object? Function() result = noop])
    : _result = result {
  polygonStart = () {
    _line = 0;
  };
  polygonEnd = () {
    _line = 1;
  };
  lineStart = () {
    _point = 0;
  };
  lineEnd = () {
    if (_line == 0) closePath();
    _point = 2;
  };
  point = (p) {
    var x = p[0], y = p[1];
    switch (_point) {
      case 0:
        moveTo(x, y);
        _point = 1;
        break;
      case 1:
        lineTo(x, y);
        break;
      default:
        moveTo(x + _radius, y);
        arc(x, y, _radius, 0, tau);
    }
  };
}