mirror of
https://github.com/esphome/esphome.git
synced 2025-11-19 08:15:49 +00:00
Fix for #6614- use background_color, improve anti-aliasing (#6618)
This commit is contained in:
@@ -129,7 +129,13 @@ void Font::print(int x_start, int y_start, display::Display *display, Color colo
|
||||
|
||||
uint8_t bitmask = 0;
|
||||
uint8_t pixel_data = 0;
|
||||
float bpp_max = (1 << this->bpp_) - 1;
|
||||
uint8_t bpp_max = (1 << this->bpp_) - 1;
|
||||
auto diff_r = (float) color.r - (float) background.r;
|
||||
auto diff_g = (float) color.g - (float) background.g;
|
||||
auto diff_b = (float) color.b - (float) background.b;
|
||||
auto b_r = (float) background.r;
|
||||
auto b_g = (float) background.g;
|
||||
auto b_b = (float) background.g;
|
||||
for (int glyph_y = y_start + scan_y1; glyph_y != max_y; glyph_y++) {
|
||||
for (int glyph_x = x_at + scan_x1; glyph_x != max_x; glyph_x++) {
|
||||
uint8_t pixel = 0;
|
||||
@@ -146,12 +152,9 @@ void Font::print(int x_start, int y_start, display::Display *display, Color colo
|
||||
if (pixel == bpp_max) {
|
||||
display->draw_pixel_at(glyph_x, glyph_y, color);
|
||||
} else if (pixel != 0) {
|
||||
float on = (float) pixel / bpp_max;
|
||||
float off = 1.0 - on;
|
||||
Color blended;
|
||||
blended.r = color.r * on + background.r * off;
|
||||
blended.g = color.r * on + background.g * off;
|
||||
blended.b = color.r * on + background.b * off;
|
||||
auto on = (float) pixel / (float) bpp_max;
|
||||
auto blended =
|
||||
Color((uint8_t) (diff_r * on + b_r), (uint8_t) (diff_g * on + b_g), (uint8_t) (diff_b * on + b_b));
|
||||
display->draw_pixel_at(glyph_x, glyph_y, blended);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user