class PDF::Reader::Rectangle

PDFs represent rectangles all over the place. They’re 4 element arrays, like this:

[A, B, C, D]

Four element arrays are yucky to work with though, so here’s a class that’s better. Initialize it with the 4 elements, and get utility functions (width, height, etc) for free.

By convention the first two elements are x1, y1, the co-ords for the bottom left corner of the rectangle. The third and fourth elements are x2, y2, the co-ords for the top left corner of the rectangle. It’s valid for the alternative corners to be used though, so we don’t assume which is which.