pointToTopLeft method

PdfPoint pointToTopLeft(
  1. double x,
  2. double y
)

Converts a point from the user space to "top-left" coordinates.

Implementation

PdfPoint pointToTopLeft(double x, double y) {
  final px = x - box.left;
  final py = box.top - y;

  final double xr;
  final double yr;
  switch (rotation) {
    case PdfPageRotation.none:
      xr = px;
      yr = py;
    case PdfPageRotation.rotate90:
      xr = box.height - py;
      yr = px;
    case PdfPageRotation.rotate180:
      xr = box.width - px;
      yr = box.height - py;
    case PdfPageRotation.rotate270:
      xr = py;
      yr = box.width - px;
  }

  return PdfPoint(xr * userUnit, yr * userUnit);
}