24 Rectangle() : x_(0), y_(0), width_(0), height_(0) {}
27 : x_(0), y_(0), width_(max(0, width)), height_(max(0, height))
31 Rectangle(int16_t x, int16_t y, int16_t width, int16_t height)
32 : x_(x), y_(y), width_(max(0, width)), height_(max(0, height))
31 Rectangle(int16_t x, int16_t y, int16_t width, int16_t height) {
…}
42 width_ = other.width_;
43 height_ = other.height_;
49 return (x_ == other.x_) && (y_ == other.y_) && (width_ == other.width_)
50 && (height_ == other.height_);
54 bool IsEmpty()
const {
return (width_ <= 0) || (height_ <= 0); }
56 int16_t
GetX()
const {
return x_; }
57 int16_t
GetY()
const {
return y_; }
60 int16_t
GetRight()
const {
return x_ + width_; }
69 return {x_, y_, width, height_};
73 return {x_, y_, width_, height};
77 return {x_, y_, width, height};
97 return {int16_t(x_ + sizeToReduce),
98 int16_t(y_ + sizeToReduce),
99 int16_t(width_ - 2 * sizeToReduce),
100 int16_t(height_ - 2 * sizeToReduce)};
104 return {int16_t(x_ + xToReduce),
105 int16_t(y_ + yToReduce),
106 int16_t(width_ - 2 * xToReduce),
107 int16_t(height_ - 2 * yToReduce)};
112 return {int16_t(x_ + x), int16_t(y_ + y), width_, height_};
117 const auto newWidth = int16_t((x_ -
left) + width_);
118 return {
left, y_, newWidth, height_};
123 const auto newWidth = int16_t(
right - x_);
124 return {x_, y_, newWidth, height_};
129 const auto newHeight = int16_t((y_ - top) + height_);
130 return {x_, top, width_, newHeight};
135 const auto newHeight = int16_t(bottom - y_);
136 return {x_, y_, width_, newHeight};
142 int16_t(x_ + pxToTrim), y_, int16_t(width_ - pxToTrim), height_};
147 return {x_, y_, int16_t(width_ - pxToTrim), height_};
153 x_, int16_t(y_ + pxToTrim), width_, int16_t(height_ - pxToTrim)};
158 return {x_, y_, width_, int16_t(height_ - pxToTrim)};
163 return {int16_t(x_ + centerX -
GetCenterX()), y_, width_, height_};
168 return {x_, int16_t(y_ + centerY -
GetCenterY()), width_, height_};
181 const auto result = this->
WithWidth(min(pxToRemove, width_));
182 x_ += min(pxToRemove, width_);
183 width_ = max(int16_t(width_ - pxToRemove), 0);
189 const auto canRemove = min(pxToRemove, width_);
191 return {int16_t(x_ + width_), y_, canRemove, height_};
196 const auto result = this->
WithHeight(min(pxToRemove, height_));
197 y_ += min(pxToRemove, height_);
198 height_ = max(height_ - pxToRemove, 0);
204 const auto canRemove = min(pxToRemove, height_);
205 height_ -= canRemove;
206 return {x_, int16_t(y_ + height_), width_, canRemove};
214 return {other.x_, other.y_, width_, height_};
216 return {int16_t(other.
GetRight() - width_),
231 return {int16_t(other.
GetRight() - width_),
246 return {int16_t(other.
GetRight() - width_),
260 int16_t x_, y_, width_, height_;
261 int16_t max(int16_t a, int16_t b) {
return (a > b) ? a : b; }
262 int16_t min(int16_t a, int16_t b) {
return (a < b) ? a : b; }
Definition graphics_common.h:22
Rectangle WithTop(int16_t top) const
Definition graphics_common.h:127
Rectangle WithCenterX(int16_t centerX) const
Definition graphics_common.h:161
Rectangle WithX(int16_t x) const
Definition graphics_common.h:65
int16_t GetY() const
Definition graphics_common.h:57
int16_t GetRight() const
Definition graphics_common.h:60
bool operator!=(const Rectangle &other) const
Definition graphics_common.h:52
Rectangle RemoveFromRight(int16_t pxToRemove)
Definition graphics_common.h:187
Rectangle WithCenterY(int16_t centerY) const
Definition graphics_common.h:166
Rectangle WithRight(int16_t right) const
Definition graphics_common.h:121
Rectangle RemoveFromBottom(int16_t pxToRemove)
Definition graphics_common.h:202
int16_t GetWidth() const
Definition graphics_common.h:58
Rectangle WithWidth(int16_t width) const
Definition graphics_common.h:67
Rectangle RemoveFromLeft(int16_t pxToRemove)
Definition graphics_common.h:179
Rectangle AlignedWithin(const Rectangle &other, Alignment alignment) const
Definition graphics_common.h:209
Rectangle WithTrimmedLeft(int16_t pxToTrim) const
Definition graphics_common.h:139
Rectangle(int16_t width, int16_t height)
Definition graphics_common.h:26
Rectangle WithCenter(int16_t centerX, int16_t centerY) const
Definition graphics_common.h:171
Rectangle Reduced(int16_t sizeToReduce) const
Definition graphics_common.h:95
Rectangle WithWidthKeepingCenter(int16_t width) const
Definition graphics_common.h:79
Rectangle WithSizeKeepingCenter(int16_t width, int16_t height) const
Definition graphics_common.h:89
int16_t GetBottom() const
Definition graphics_common.h:61
bool operator==(const Rectangle &other) const
Definition graphics_common.h:47
Rectangle RemoveFromTop(int16_t pxToRemove)
Definition graphics_common.h:194
Rectangle(const Rectangle &other)
Definition graphics_common.h:36
int16_t GetHeight() const
Definition graphics_common.h:59
int16_t GetCenterY() const
Definition graphics_common.h:63
bool IsEmpty() const
Definition graphics_common.h:54
Rectangle WithHeightKeepingCenter(int16_t height) const
Definition graphics_common.h:84
Rectangle Reduced(int16_t xToReduce, int16_t yToReduce) const
Definition graphics_common.h:102
int16_t GetCenterX() const
Definition graphics_common.h:62
Rectangle(int16_t x, int16_t y, int16_t width, int16_t height)
Definition graphics_common.h:31
Rectangle WithSize(int16_t width, int16_t height) const
Definition graphics_common.h:75
int16_t GetX() const
Definition graphics_common.h:56
Rectangle & operator=(const Rectangle &other)
Definition graphics_common.h:38
Rectangle WithHeight(int16_t height) const
Definition graphics_common.h:71
Rectangle WithBottom(int16_t bottom) const
Definition graphics_common.h:133
Rectangle WithTrimmedTop(int16_t pxToTrim) const
Definition graphics_common.h:150
Rectangle WithTrimmedRight(int16_t pxToTrim) const
Definition graphics_common.h:145
Rectangle WithY(int16_t y) const
Definition graphics_common.h:66
Rectangle WithTrimmedBottom(int16_t pxToTrim) const
Definition graphics_common.h:156
Rectangle()
Definition graphics_common.h:24
Rectangle Translated(int16_t x, int16_t y) const
Definition graphics_common.h:110
Rectangle WithLeft(int16_t left) const
Definition graphics_common.h:115
Hardware defines and helpers for daisy field platform.
Definition index.h:2
Alignment
Definition graphics_common.h:9