ESPHome 2025.5.0
Loading...
Searching...
No Matches
rect.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace esphome {
6namespace display {
7
8static const int16_t VALUE_NO_SET = 32766;
9
10class Rect {
11 public:
12 int16_t x;
13 int16_t y;
14 int16_t w;
15 int16_t h;
16
17 Rect() : x(VALUE_NO_SET), y(VALUE_NO_SET), w(VALUE_NO_SET), h(VALUE_NO_SET) {} // NOLINT
18 inline Rect(int16_t x, int16_t y, int16_t w, int16_t h) ESPHOME_ALWAYS_INLINE : x(x), y(y), w(w), h(h) {}
19 inline int16_t x2() const { return this->x + this->w; };
20 inline int16_t y2() const { return this->y + this->h; };
21
22 inline bool is_set() const ESPHOME_ALWAYS_INLINE { return (this->h != VALUE_NO_SET) && (this->w != VALUE_NO_SET); }
23
24 void expand(int16_t horizontal, int16_t vertical);
25
26 void extend(Rect rect);
27 void shrink(Rect rect);
28
29 bool inside(Rect rect) const;
30 bool inside(int16_t test_x, int16_t test_y, bool absolute = true) const;
31 bool equal(Rect rect) const;
32 void info(const std::string &prefix = "rect info:");
33};
34
35} // namespace display
36} // namespace esphome
int16_t x2() const
Definition rect.h:19
int16_t x
X coordinate of corner.
Definition rect.h:12
int16_t h
Height of region.
Definition rect.h:15
int16_t y
Y coordinate of corner.
Definition rect.h:13
void shrink(Rect rect)
Definition rect.cpp:42
void info(const std::string &prefix="rect info:")
Definition rect.cpp:84
void expand(int16_t horizontal, int16_t vertical)
Definition rect.cpp:10
bool inside(Rect rect) const
Definition rect.cpp:77
Rect(int16_t x, int16_t y, int16_t w, int16_t h) ESPHOME_ALWAYS_INLINE
Definition rect.h:18
bool is_set() const ESPHOME_ALWAYS_INLINE
Y coordinate of corner.
Definition rect.h:22
void extend(Rect rect)
Definition rect.cpp:19
bool equal(Rect rect) const
Definition rect.cpp:63
int16_t y2() const
X coordinate of corner.
Definition rect.h:20
int16_t w
Width of region.
Definition rect.h:14
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7