🤓 remove duplicated trail drawing logic
This commit is contained in:
parent
638f74b6c3
commit
971b1cd042
@ -18,6 +18,7 @@ typedef struct {
|
||||
unsigned long last_moved;
|
||||
} Raindrop;
|
||||
|
||||
// TODO: Use a dynamic vector instead
|
||||
Raindrop raindrops[PANEL_WIDTH];
|
||||
bool rain_initialized = false;
|
||||
uint16_t color_highlight;
|
||||
@ -72,42 +73,49 @@ void draw_rain(MatrixPanel_I2S_DMA *matrix, Mode mode) {
|
||||
COLOR_DEFAULT_B * brightness
|
||||
);
|
||||
|
||||
if (trail_y >= 0) {
|
||||
int pixel_num = (trail_y * PANEL_WIDTH) + x;
|
||||
if (overlay[pixel_num / 8] & (1 << (7 - (pixel_num % 8))) and mode != Stealth) {
|
||||
if (mode == HighVis) {
|
||||
matrix->drawPixel(x, trail_y, color_highlight);
|
||||
} else {
|
||||
matrix->drawPixel(x, trail_y, matrix->color565(
|
||||
COLOR_HIGHLIGHT_R * brightness,
|
||||
COLOR_HIGHLIGHT_G * brightness,
|
||||
COLOR_HIGHLIGHT_B * brightness
|
||||
));
|
||||
}
|
||||
} else {
|
||||
matrix->drawPixel(x, trail_y, fade_color);
|
||||
}
|
||||
} else if (raindrops[x].reached_bottom) {
|
||||
int pixel_num = ((PANEL_HEIGHT + trail_y) * PANEL_WIDTH) + x;
|
||||
if (raindrops[x].y >= 0) {
|
||||
|
||||
if (overlay[ pixel_num / 8 ] & (1 << (7 - (pixel_num % 8)) ) and mode != Stealth) {
|
||||
if (mode == HighVis) {
|
||||
matrix->drawPixel(x, PANEL_HEIGHT + trail_y, color_highlight);
|
||||
} else {
|
||||
matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(
|
||||
COLOR_HIGHLIGHT_R * brightness,
|
||||
COLOR_HIGHLIGHT_G * brightness,
|
||||
COLOR_HIGHLIGHT_B * brightness
|
||||
));
|
||||
}
|
||||
} else {
|
||||
matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(0, fade_color, 0));
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
if (trail_y < 0) {
|
||||
if (not raindrops[x].reached_bottom) {
|
||||
continue;
|
||||
}
|
||||
// we need to count from the bottom up
|
||||
trail_y = PANEL_WIDTH + trail_y;
|
||||
}
|
||||
|
||||
int pixel_num = (trail_y * PANEL_WIDTH) + x;
|
||||
if (overlay[pixel_num / 8] & (1 << (7 - (pixel_num % 8))) and mode != Stealth) {
|
||||
if (mode == HighVis) {
|
||||
matrix->drawPixel(x, trail_y, color_highlight);
|
||||
} else {
|
||||
matrix->drawPixel(x, trail_y, matrix->color565(
|
||||
COLOR_HIGHLIGHT_R * brightness,
|
||||
COLOR_HIGHLIGHT_G * brightness,
|
||||
COLOR_HIGHLIGHT_B * brightness
|
||||
));
|
||||
}
|
||||
} else {
|
||||
matrix->drawPixel(x, trail_y, fade_color);
|
||||
}
|
||||
|
||||
//} else if (raindrops[x].reached_bottom) {
|
||||
// int pixel_num = ((PANEL_HEIGHT + trail_y) * PANEL_WIDTH) + x;
|
||||
// if (raindrops[x].y >= 0) {
|
||||
// if (overlay[ pixel_num / 8 ] & (1 << (7 - (pixel_num % 8)) ) and mode != Stealth) {
|
||||
// if (mode == HighVis) {
|
||||
// matrix->drawPixel(x, PANEL_HEIGHT + trail_y, color_highlight);
|
||||
// } else {
|
||||
// matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(
|
||||
// COLOR_HIGHLIGHT_R * brightness,
|
||||
// COLOR_HIGHLIGHT_G * brightness,
|
||||
// COLOR_HIGHLIGHT_B * brightness
|
||||
// ));
|
||||
// }
|
||||
// } else {
|
||||
// matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(0, fade_color, 0));
|
||||
// }
|
||||
// } else {
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user