paint method

  1. @override
void paint(
  1. PCanvas pCanvas
)
override

The paint operation of this element.

Implementation

@override
void paint(PCanvas pCanvas) {
  var prevState = pCanvas.saveState();

  final prevT = pCanvas.transform;

  final boundingBox = this.boundingBox;
  final boundingBoxTransformed = boundingBox.transform(prevT);

  final t =
      PcanvasTransform(translateX: boundingBox.x, translateY: boundingBox.y);

  try {
    pCanvas.subTransform = t;
    pCanvas.subClip = boundingBoxTransformed;

    paintBackground(pCanvas);

    var paintRect = dimension.toPRectangle();

    for (var e in elements) {
      var eBox = e.boundingBox;

      if (!paintRect.intersectsRectangle(eBox)) {
        continue;
      }

      e.paint(pCanvas);
    }
  } finally {
    pCanvas.restoreState(expectedState: prevState);
  }
}