Merge pull request #778 from tremby/blazing-smooth

Tweak blazing trail decay
pull/781/head
Gergely Nagy 5 years ago committed by GitHub
commit 5154e93052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -105,27 +105,32 @@ cRGB Haunt::compute(uint8_t *step) {
// BlazingTrail // BlazingTrail
BlazingTrail::BlazingTrail(void) { BlazingTrail::BlazingTrail(void) {
} }
constexpr uint8_t hue_start = 50.0 / 360 * 0xff;
constexpr uint8_t hue_end = 0;
cRGB BlazingTrail::compute(uint8_t *step) { cRGB BlazingTrail::compute(uint8_t *step) {
cRGB color; cRGB color;
if (*step >= 0xff - 30) { // Get the position in the animation, where 0 is start and 0xff is end
color = hsvToRgb(0xff - *step, 255, 255); uint8_t pos255 = 0xff - *step;
} else {
color = hsvToRgb(30, 255, 255);
color.r = min(*step * color.r / 255, 255); // Fade hue linearly from orange to red
color.g = min(*step * color.g / 255, 255); uint8_t hue = hue_start + (pos255 * (hue_end - hue_start) >> 8);
}
if (*step >= 0xff - 30) // Fade value from full following a 1-x^4 curve
*step -= 1; uint8_t val =
else if (*step >= 0x40) 0xff // Maximum brightness
*step -= 16; - ((uint32_t) pos255 * pos255 * pos255 * pos255 // Animation position to 4th power
else if (*step >= 32) >> 24) // ...pulled down to 8-bit range (but this has a maximum of 0xfc rather than 0xff)
*step -= 32; - pos255 / (0x100 / 4); // Correction to bring the end result into a full 0 to 0xff range
else
color = hsvToRgb(hue, 0xff, val);
if (*step < 4) {
*step = 0; *step = 0;
} else {
*step -= 4;
}
return color; return color;
} }

Loading…
Cancel
Save