mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	| @@ -32,9 +32,11 @@ void Rect::extend(Rect rect) { | |||||||
|     this->h = rect.h; |     this->h = rect.h; | ||||||
|   } else { |   } else { | ||||||
|     if (this->x > rect.x) { |     if (this->x > rect.x) { | ||||||
|  |       this->w = this->w + (this->x - rect.x); | ||||||
|       this->x = rect.x; |       this->x = rect.x; | ||||||
|     } |     } | ||||||
|     if (this->y > rect.y) { |     if (this->y > rect.y) { | ||||||
|  |       this->h = this->h + (this->y - rect.y); | ||||||
|       this->y = rect.y; |       this->y = rect.y; | ||||||
|     } |     } | ||||||
|     if (this->x2() < rect.x2()) { |     if (this->x2() < rect.x2()) { | ||||||
| @@ -49,29 +51,35 @@ void Rect::shrink(Rect rect) { | |||||||
|   if (!this->inside(rect)) { |   if (!this->inside(rect)) { | ||||||
|     (*this) = Rect(); |     (*this) = Rect(); | ||||||
|   } else { |   } else { | ||||||
|     if (this->x < rect.x) { |  | ||||||
|       this->x = rect.x; |  | ||||||
|     } |  | ||||||
|     if (this->y < rect.y) { |  | ||||||
|       this->y = rect.y; |  | ||||||
|     } |  | ||||||
|     if (this->x2() > rect.x2()) { |     if (this->x2() > rect.x2()) { | ||||||
|       this->w = rect.x2() - this->x; |       this->w = rect.x2() - this->x; | ||||||
|     } |     } | ||||||
|  |     if (this->x < rect.x) { | ||||||
|  |       this->w = this->w + (this->x - rect.x); | ||||||
|  |       this->x = rect.x; | ||||||
|  |     } | ||||||
|     if (this->y2() > rect.y2()) { |     if (this->y2() > rect.y2()) { | ||||||
|       this->h = rect.y2() - this->y; |       this->h = rect.y2() - this->y; | ||||||
|     } |     } | ||||||
|  |     if (this->y < rect.y) { | ||||||
|  |       this->h = this->h + (this->y - rect.y); | ||||||
|  |       this->y = rect.y; | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| bool Rect::inside(int16_t x, int16_t y, bool absolute) {  // NOLINT | bool Rect::equal(Rect rect) { | ||||||
|  |   return (rect.x == this->x) && (rect.w == this->w) && (rect.y == this->y) && (rect.h == this->h); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | bool Rect::inside(int16_t test_x, int16_t test_y, bool absolute) {  // NOLINT | ||||||
|   if (!this->is_set()) { |   if (!this->is_set()) { | ||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
|   if (absolute) { |   if (absolute) { | ||||||
|     return ((x >= 0) && (x <= this->w) && (y >= 0) && (y <= this->h)); |     return ((test_x >= this->x) && (test_x <= this->x2()) && (test_y >= this->y) && (test_y <= this->y2())); | ||||||
|   } else { |   } else { | ||||||
|     return ((x >= this->x) && (x <= this->x2()) && (y >= this->y) && (y <= this->y2())); |     return ((test_x >= 0) && (test_x <= this->w) && (test_y >= 0) && (test_y <= this->h)); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -80,15 +88,16 @@ bool Rect::inside(Rect rect, bool absolute) { | |||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
|   if (absolute) { |   if (absolute) { | ||||||
|     return ((rect.x <= this->w) && (rect.w >= 0) && (rect.y <= this->h) && (rect.h >= 0)); |  | ||||||
|   } else { |  | ||||||
|     return ((rect.x <= this->x2()) && (rect.x2() >= this->x) && (rect.y <= this->y2()) && (rect.y2() >= this->y)); |     return ((rect.x <= this->x2()) && (rect.x2() >= this->x) && (rect.y <= this->y2()) && (rect.y2() >= this->y)); | ||||||
|  |   } else { | ||||||
|  |     return ((rect.x <= this->w) && (rect.w >= 0) && (rect.y <= this->h) && (rect.h >= 0)); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| void Rect::info(const std::string &prefix) { | void Rect::info(const std::string &prefix) { | ||||||
|   if (this->is_set()) { |   if (this->is_set()) { | ||||||
|     ESP_LOGI(TAG, "%s [%3d,%3d,%3d,%3d]", prefix.c_str(), this->x, this->y, this->w, this->h); |     ESP_LOGI(TAG, "%s [%3d,%3d,%3d,%3d] (%3d,%3d)", prefix.c_str(), this->x, this->y, this->w, this->h, this->x2(), | ||||||
|  |              this->y2()); | ||||||
|   } else |   } else | ||||||
|     ESP_LOGI(TAG, "%s ** IS NOT SET **", prefix.c_str()); |     ESP_LOGI(TAG, "%s ** IS NOT SET **", prefix.c_str()); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -120,8 +120,9 @@ class Rect { | |||||||
|   void extend(Rect rect); |   void extend(Rect rect); | ||||||
|   void shrink(Rect rect); |   void shrink(Rect rect); | ||||||
|  |  | ||||||
|   bool inside(Rect rect, bool absolute = false); |   bool inside(Rect rect, bool absolute = true); | ||||||
|   bool inside(int16_t x, int16_t y, bool absolute = false); |   bool inside(int16_t test_x, int16_t test_y, bool absolute = true); | ||||||
|  |   bool equal(Rect rect); | ||||||
|   void info(const std::string &prefix = "rect info:"); |   void info(const std::string &prefix = "rect info:"); | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| """Constants used by esphome.""" | """Constants used by esphome.""" | ||||||
|  |  | ||||||
| __version__ = "2023.3.0b5" | __version__ = "2023.3.0b6" | ||||||
|  |  | ||||||
| ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" | ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user