ESPHome
2025.5.2
Toggle main menu visibility
Main Page
Topics
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
y
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Typedefs
a
b
d
e
f
i
j
l
m
n
o
p
q
r
s
t
u
v
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Enumerator
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
c
d
o
p
s
t
v
w
Enumerations
b
c
e
f
i
m
n
p
r
s
t
v
w
Enumerator
a
b
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
w
Related Symbols
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
l
m
o
p
s
t
u
Variables
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Typedefs
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Modules
Pages
Loading...
Searching...
No Matches
esphome
components
display
rect.cpp
Go to the documentation of this file.
1
#include "
rect.h
"
2
3
#include "
esphome/core/log.h
"
4
5
namespace
esphome
{
6
namespace
display {
7
8
static
const
char
*
const
TAG =
"display"
;
9
10
void
Rect::expand
(int16_t horizontal, int16_t vertical) {
11
if
(this->
is_set
() && (this->
w
>= (-2 * horizontal)) && (this->
h
>= (-2 * vertical))) {
12
this->
x
= this->
x
- horizontal;
13
this->
y
= this->
y
- vertical;
14
this->
w
= this->
w
+ (2 * horizontal);
15
this->
h
= this->h + (2 * vertical);
16
}
17
}
10
void
Rect::expand
(int16_t horizontal, int16_t vertical) {
…
}
18
19
void
Rect::extend
(
Rect
rect) {
20
if
(!this->
is_set
()) {
21
this->
x
= rect.
x
;
22
this->
y
= rect.
y
;
23
this->
w
= rect.
w
;
24
this->
h
= rect.
h
;
25
}
else
{
26
if
(this->
x
> rect.
x
) {
27
this->
w
= this->
w
+ (this->
x
- rect.
x
);
28
this->
x
= rect.
x
;
29
}
30
if
(this->
y
> rect.
y
) {
31
this->
h
= this->
h
+ (this->
y
- rect.
y
);
32
this->
y
= rect.
y
;
33
}
34
if
(this->
x2
() < rect.
x2
()) {
35
this->
w
= rect.
x2
() - this->
x
;
36
}
37
if
(this->
y2
() < rect.
y2
()) {
38
this->
h
= rect.
y2
() - this->
y
;
39
}
40
}
41
}
19
void
Rect::extend
(
Rect
rect) {
…
}
42
void
Rect::shrink
(
Rect
rect) {
43
if
(!this->
inside
(rect)) {
44
(*this) =
Rect
();
45
}
else
{
46
if
(this->
x2
() > rect.
x2
()) {
47
this->
w
= rect.
x2
() - this->
x
;
48
}
49
if
(this->
x
< rect.
x
) {
50
this->
w
= this->
w
+ (this->
x
- rect.
x
);
51
this->
x
= rect.
x
;
52
}
53
if
(this->
y2
() > rect.
y2
()) {
54
this->
h
= rect.
y2
() - this->
y
;
55
}
56
if
(this->
y
< rect.
y
) {
57
this->
h
= this->
h
+ (this->
y
- rect.
y
);
58
this->
y
= rect.
y
;
59
}
60
}
61
}
42
void
Rect::shrink
(
Rect
rect) {
…
}
62
63
bool
Rect::equal
(
Rect
rect)
const
{
64
return
(rect.
x
== this->x) && (rect.
w
== this->
w
) && (rect.
y
== this->y) && (rect.
h
== this->
h
);
65
}
63
bool
Rect::equal
(
Rect
rect)
const
{
…
}
66
67
bool
Rect::inside
(int16_t test_x, int16_t test_y,
bool
absolute)
const
{
// NOLINT
68
if
(!this->
is_set
()) {
69
return
true
;
70
}
71
if
(absolute) {
72
return
test_x >= this->
x
&& test_x < this->
x2
() && test_y >= this->
y
&& test_y < this->
y2
();
73
}
74
return
test_x >= 0 && test_x < this->
w
&& test_y >= 0 && test_y < this->
h
;
75
}
67
bool
Rect::inside
(int16_t test_x, int16_t test_y,
bool
absolute)
const
{
// NOLINT
{
…
}
76
77
bool
Rect::inside
(
Rect
rect)
const
{
78
if
(!this->
is_set
() || !rect.
is_set
()) {
79
return
true
;
80
}
81
return
this->
x2
() >= rect.
x
&& this->
x
<= rect.
x2
() && this->
y2
() >= rect.
y
&& this->
y
<= rect.
y2
();
82
}
77
bool
Rect::inside
(
Rect
rect)
const
{
…
}
83
84
void
Rect::info
(
const
std::string &prefix) {
85
if
(this->
is_set
()) {
86
ESP_LOGI(TAG,
"%s [%3d,%3d,%3d,%3d] (%3d,%3d)"
, prefix.c_str(), this->x, this->y, this->w, this->h, this->x2(),
87
this->y2());
88
}
else
{
89
ESP_LOGI(TAG,
"%s ** IS NOT SET **"
, prefix.c_str());
90
}
91
}
84
void
Rect::info
(
const
std::string &prefix) {
…
}
92
93
}
// namespace display
94
}
// namespace esphome
esphome::display::Rect
Definition
rect.h:10
esphome::display::Rect::x2
int16_t x2() const
Definition
rect.h:19
esphome::display::Rect::x
int16_t x
X coordinate of corner.
Definition
rect.h:12
esphome::display::Rect::h
int16_t h
Height of region.
Definition
rect.h:15
esphome::display::Rect::y
int16_t y
Y coordinate of corner.
Definition
rect.h:13
esphome::display::Rect::shrink
void shrink(Rect rect)
Definition
rect.cpp:42
esphome::display::Rect::info
void info(const std::string &prefix="rect info:")
Definition
rect.cpp:84
esphome::display::Rect::expand
void expand(int16_t horizontal, int16_t vertical)
Definition
rect.cpp:10
esphome::display::Rect::inside
bool inside(Rect rect) const
Definition
rect.cpp:77
esphome::display::Rect::is_set
bool is_set() const ESPHOME_ALWAYS_INLINE
Y coordinate of corner.
Definition
rect.h:22
esphome::display::Rect::extend
void extend(Rect rect)
Definition
rect.cpp:19
esphome::display::Rect::equal
bool equal(Rect rect) const
Definition
rect.cpp:63
esphome::display::Rect::y2
int16_t y2() const
X coordinate of corner.
Definition
rect.h:20
esphome::display::Rect::Rect
Rect()
Definition
rect.h:17
esphome::display::Rect::w
int16_t w
Width of region.
Definition
rect.h:14
log.h
esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition
a01nyub.cpp:7
rect.h
Generated by
1.12.0