File indexing completed on 2026-05-10 08:48:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #ifndef PDFRECTANGLE_H
0028 #define PDFRECTANGLE_H
0029
0030
0031
0032 class PDFRectangle
0033 {
0034 public:
0035 double x1 = 0.0;
0036 double y1 = 0.0;
0037 double x2 = 0.0;
0038 double y2 = 0.0;
0039
0040 constexpr PDFRectangle() = default;
0041 constexpr PDFRectangle(double x1A, double y1A, double x2A, double y2A)
0042 {
0043 x1 = x1A;
0044 y1 = y1A;
0045 x2 = x2A;
0046 y2 = y2A;
0047 }
0048 constexpr bool isValid() const { return x1 != 0 || y1 != 0 || x2 != 0 || y2 != 0; }
0049 constexpr bool isEmpty() const { return x1 == x2 && y1 == y2; }
0050 constexpr bool contains(double x, double y) const { return x1 <= x && x <= x2 && y1 <= y && y <= y2; }
0051 constexpr void clipTo(const PDFRectangle &rect);
0052
0053 constexpr bool operator==(const PDFRectangle &rect) const { return x1 == rect.x1 && y1 == rect.y1 && x2 == rect.x2 && y2 == rect.y2; }
0054 };
0055
0056 constexpr void PDFRectangle::clipTo(const PDFRectangle &rect)
0057 {
0058 if (x1 < rect.x1) {
0059 x1 = rect.x1;
0060 } else if (x1 > rect.x2) {
0061 x1 = rect.x2;
0062 }
0063 if (x2 < rect.x1) {
0064 x2 = rect.x1;
0065 } else if (x2 > rect.x2) {
0066 x2 = rect.x2;
0067 }
0068 if (y1 < rect.y1) {
0069 y1 = rect.y1;
0070 } else if (y1 > rect.y2) {
0071 y1 = rect.y2;
0072 }
0073 if (y2 < rect.y1) {
0074 y2 = rect.y1;
0075 } else if (y2 > rect.y2) {
0076 y2 = rect.y2;
0077 }
0078 }
0079
0080 #endif