endShape method

void endShape({
  1. bool close = false,
})

Ends the definition of a custom shape and then paints it.

The endShape() function is the companion to beginShape() and may only be called after beginShape(). When endShape() is called, all of image data defined since the previous call to beginShape() is written into the image buffer. Pass true for close to close the shape (to connect the beginning and the end).

Implementation

void endShape({bool close = false}) {
  if (_shape == null) {
    throw Exception("Can't end a shape because a shape was not started.");
  }

  if (_shape!.mode == null) {
    _drawDefault(closeShape: close);
  } else {
    switch (_shape!.mode!) {
      case ShapeMode.points:
        _drawPoints();
        break;
      case ShapeMode.lines:
        _drawLines(closeShape: close);
        break;
      case ShapeMode.triangles:
        _drawTriangles();
        break;
      case ShapeMode.triangleFan:
        _drawTriangleFan();
        break;
      case ShapeMode.triangleStrip:
        _drawTriangleStrip();
        break;
      case ShapeMode.quads:
        _drawQuads();
        break;
      case ShapeMode.quadStrip:
        _drawQuadStrip();
        break;
    }
  }

  _shape = null;
}