| 606 | } |
| 607 | |
| 608 | void fillFrameBufferFire(uint32_t now) { |
| 609 | fl::CRGBPalette16 myPal = getFirePalette(); |
| 610 | |
| 611 | // Calculate the current y-offset for animation (makes the fire move) |
| 612 | uint32_t y_speed = now * fireSpeedY.value(); |
| 613 | |
| 614 | int width = frameBufferPtr->width(); |
| 615 | int height = frameBufferPtr->height(); |
| 616 | |
| 617 | // Loop through every pixel in our cylindrical matrix |
| 618 | for (int w = 0; w < width; w++) { |
| 619 | for (int h = 0; h < height; h++) { |
| 620 | // Calculate which color to use from our palette for this pixel |
| 621 | uint8_t palette_index = |
| 622 | getFirePaletteIndex(now, w, width, h, height, y_speed); |
| 623 | |
| 624 | // Get the actual RGB color from the palette |
| 625 | fl::CRGB color = ColorFromPalette(myPal, palette_index, 255); |
| 626 | |
| 627 | // Apply color boost using ease functions |
| 628 | fl::EaseType sat_ease = getEaseType(saturationFunction.value()); |
| 629 | fl::EaseType lum_ease = getEaseType(luminanceFunction.value()); |
| 630 | color = color.colorBoost(sat_ease, lum_ease); |
| 631 | |
| 632 | // Set the pixel in the frame buffer |
| 633 | // Flip coordinates to make fire rise from bottom |
| 634 | frameBufferPtr->at((width - 1) - w, (height - 1) - h) = color; |
| 635 | } |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | void drawFire(uint32_t now) { |
| 640 | fillFrameBufferFire(now); |
no test coverage detected