Home | History | Annotate | Download | only in cpp

Lines Matching full:rect

5 #include "ppapi/cpp/rect.h"
26 void Rect::Inset(int32_t left, int32_t top, int32_t right, int32_t bottom) {
32 void Rect::Offset(int32_t horizontal, int32_t vertical) {
37 bool Rect::Contains(int32_t point_x, int32_t point_y) const {
42 bool Rect::Contains(const Rect& rect) const {
43 return (rect.x() >= x() && rect.right() <= right() &&
44 rect.y() >= y() && rect.bottom() <= bottom());
47 bool Rect::Intersects(const Rect& rect) const {
48 return !(rect.x() >= right() || rect.right() <= x() ||
49 rect.y() >= bottom() || rect.bottom() <= y());
52 Rect Rect::Intersect(const Rect& rect) const {
53 int32_t rx = std::max(x(), rect.x());
54 int32_t ry = std::max(y(), rect.y());
55 int32_t rr = std::min(right(), rect.right());
56 int32_t rb = std::min(bottom(), rect.bottom());
61 return Rect(rx, ry, rr - rx, rb - ry);
64 Rect Rect::Union(const Rect& rect) const {
67 return rect;
68 if (rect.IsEmpty())
71 int32_t rx = std::min(x(), rect.x());
72 int32_t ry = std::min(y(), rect.y());
73 int32_t rr = std::max(right(), rect.right());
74 int32_t rb = std::max(bottom(), rect.bottom());
76 return Rect(rx, ry, rr - rx, rb - ry);
79 Rect Rect::Subtract(const Rect& rect) const {
81 if (!Intersects(rect))
83 if (rect.Contains(*this))
84 return Rect();
91 if (rect.y() <= y() && rect.bottom() >= bottom()) {
93 if (rect.x() <= x()) {
94 rx = rect.right();
96 rr = rect.x();
98 } else if (rect.x() <= x() && rect.right() >= right()) {
100 if (rect.y() <= y()) {
101 ry = rect.bottom();
103 rb = rect.y();
106 return Rect(rx, ry, rr - rx, rb - ry);
109 Rect Rect::AdjustToFit(const Rect& rect) const {
114 AdjustAlongAxis(rect.x(), rect.width(), &new_x, &new_width);
115 AdjustAlongAxis(rect.y(), rect.height(), &new_y, &new_height);
116 return Rect(new_x, new_y, new_width, new_height);
119 Point Rect::CenterPoint() const {
123 bool Rect::SharesEdgeWith(const Rect& rect) const {
124 return (y() == rect.y() && height() == rect.height() &&
125 (x() == rect.right() || right() == rect.x())) ||
126 (x() == rect.x() && width() == rect.width() &&
127 (y() == rect.bottom() || bottom() == rect.y()));