PoDoFo 1.2.0
Loading...
Searching...
No Matches
Rect.h
1// SPDX-FileCopyrightText: 2006 Dominik Seichter <domseichter@web.de>
2// SPDX-FileCopyrightText: 2020 Francesco Pretto <ceztko@gmail.com>
3// SPDX-License-Identifier: LGPL-2.0-or-later OR MPL-2.0
4
5#ifndef AUX_RECT_H
6#define AUX_RECT_H
7
8#include "Corners.h"
9
10namespace PoDoFo {
11
12class PdfArray;
13class Matrix;
14
16class PODOFO_API Rect final
17{
18public:
19 double X;
20 double Y;
21 double Width;
22 double Height;
23
24public:
26 Rect();
27
29 Rect(double x, double y, double width, double height);
30
32 Rect(const Rect& rhs) = default;
33
34public:
37 static Rect FromCorners(double x1, double y1, double x2, double y2);
38 static Rect FromCorners(const Vector2& corner1, const Vector2& corner2);
39
40 static Rect FromCorners(const Corners& corners);
41
44 static Rect FromArray(const PdfArray& arr);
45
48 void ToArray(PdfArray& arr) const;
49
50 PdfArray ToArray() const;
51
54 std::string ToString() const;
55
56 bool Contains(double x, double y) const;
57
58 // REMOVE-ME: The name of this method is bad and it's also
61 void Intersect(const Rect& rect);
62
63 bool IsValid() const;
64
65 Corners ToCorners() const;
66
67public:
69 Vector2 GetLeftBottom() const;
70
72 Vector2 GetRightTop() const;
73
75 double GetLeft() const { return X; }
76
78 double GetBottom() const { return Y; }
79
81 double GetRight() const;
82
84 double GetTop() const;
85
86public:
87 bool operator==(const Rect& rect) const;
88 bool operator!=(const Rect& rect) const;
89 Rect operator*(const Matrix& m) const;
90 Rect& operator=(const Rect& rhs) = default;
91 operator Corners() const;
92};
93
94};
95
96#endif // AUX_RECT_H
An unoriented rectangle defined by 2 points.
Definition Corners.h:16
This class represents a PdfArray Use it for all arrays that are written to a PDF file.
Definition PdfArray.h:76
An normalized rectangle defined by position (left-bottom) and size.
Definition Rect.h:17
double GetLeft() const
Get the left coordinate of the rectangle.
Definition Rect.h:75
Rect(const Rect &rhs)=default
Copy constructor.
double GetBottom() const
Get the bottom coordinate of the rectangle.
Definition Rect.h:78
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:30
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13