PoDoFo 1.0.0-dev
Loading...
Searching...
No Matches
Rect.h
1
7#ifndef AUX_RECT_H
8#define AUX_RECT_H
9
10#include "Corners.h"
11
12namespace PoDoFo {
13
14class PdfArray;
15class Matrix;
16
19class PODOFO_API Rect final
20{
21public:
22 double X;
23 double Y;
24 double Width;
25 double Height;
26
27public:
30 Rect();
31
34 Rect(double x, double y, double width, double height);
35
38 Rect(const Rect& rhs) = default;
39
40public:
44 static Rect FromCorners(double x1, double y1, double x2, double y2);
45 static Rect FromCorners(const Vector2& corner1, const Vector2& corner2);
46
47 static Rect FromCorners(const Corners& corners);
48
52 static Rect FromArray(const PdfArray& arr);
53
57 void ToArray(PdfArray& arr) const;
58
59 PdfArray ToArray() const;
60
64 std::string ToString() const;
65
66 bool Contains(double x, double y) const;
67
68 // REMOVE-ME: The name of this method is bad and it's also
72 void Intersect(const Rect& rect);
73
74 bool IsValid() const;
75
76 Corners ToCorners() const;
77
78public:
81 Vector2 GetLeftBottom() const;
82
85 Vector2 GetRightTop() const;
86
89 double GetLeft() const { return X; }
90
93 double GetBottom() const { return Y; }
94
97 double GetRight() const;
98
101 double GetTop() const;
102
103public:
104 bool operator==(const Rect& rect) const;
105 bool operator!=(const Rect& rect) const;
106 Rect operator*(const Matrix& m) const;
107 Rect& operator=(const Rect& rhs) = default;
108 operator Corners() const;
109};
110
111};
112
113#endif // AUX_RECT_H
An unoriented rectangle defined by 2 points.
Definition Corners.h:20
This class represents a PdfArray Use it for all arrays that are written to a PDF file.
Definition PdfArray.h:81
An normalized rectangle defined by position (left-bottom) and size.
Definition Rect.h:20
double GetLeft() const
Get the left coordinate of the rectangle.
Definition Rect.h:89
Rect(const Rect &rhs)=default
Copy constructor.
double GetBottom() const
Get the bottom coordinate of the rectangle.
Definition Rect.h:93
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:38
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition basetypes.h:16