mirror of
https://github.com/esphome/esphome.git
synced 2025-11-18 07:45:56 +00:00
Add line_at_angle method to Display component (#6381)
This commit is contained in:
committed by
GitHub
parent
72c6563a3b
commit
8fd10d6859
@@ -36,6 +36,21 @@ void HOT Display::line(int x1, int y1, int x2, int y2, Color color) {
|
||||
}
|
||||
}
|
||||
|
||||
void Display::line_at_angle(int x, int y, int angle, int length, Color color) {
|
||||
this->line_at_angle(x, y, angle, 0, length, color);
|
||||
}
|
||||
|
||||
void Display::line_at_angle(int x, int y, int angle, int start_radius, int stop_radius, Color color) {
|
||||
// Calculate start and end points
|
||||
int x1 = (start_radius * cos(angle * M_PI / 180)) + x;
|
||||
int y1 = (start_radius * sin(angle * M_PI / 180)) + y;
|
||||
int x2 = (stop_radius * cos(angle * M_PI / 180)) + x;
|
||||
int y2 = (stop_radius * sin(angle * M_PI / 180)) + y;
|
||||
|
||||
// Draw line
|
||||
this->line(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
void Display::draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, ColorOrder order,
|
||||
ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) {
|
||||
size_t line_stride = x_offset + w + x_pad; // length of each source line in pixels
|
||||
|
||||
Reference in New Issue
Block a user