paint method

  1. @override
void paint(
  1. Context context
)
override

Draw itself and its children, according to the calculated box.offset

Implementation

@override
void paint(Context context) {
  super.paint(context);

  final canvas = context.canvas;

  canvas.saveContext();

  if (strokeColor != null) {
    canvas.setStrokeColor(strokeColor);
  }

  canvas.setLineWidth(strokeWidth);

  // Flip the points on the Y axis.

  for (var subLineIndex = 0; subLineIndex < points.length; subLineIndex++) {
    final flippedPoints = points[subLineIndex]
        .map((e) => PdfPoint(e.x, box!.height - e.y))
        .toList();
    canvas.moveTo(flippedPoints[0].x, flippedPoints[0].y);
    for (var i = 0; i < flippedPoints.length; i++) {
      canvas.lineTo(flippedPoints[i].x, flippedPoints[i].y);
    }
  }

  canvas.strokePath();

  canvas.restoreContext();
}