FastLED 3.9.15
Loading...
Searching...
No Matches

◆ getFirePaletteIndex()

uint8_t getFirePaletteIndex ( uint32_t millis32,
int width,
int max_width,
int height,
int max_height,
uint32_t y_speed )

Definition at line 592 of file curr.h.

593 {
594 uint16_t scale = fireScaleXY.as<uint16_t>();
595
596 float xf = (float)width / (float)max_width;
597 uint8_t x = (uint8_t)(xf * 255);
598
599 uint32_t cosx = cos8(x);
600 uint32_t sinx = sin8(x);
601
602 float trig_scale = scale * fireScaleX.value();
603 cosx *= trig_scale;
604 sinx *= trig_scale;
605
606 uint32_t y = height * scale + y_speed;
607
608 uint16_t z = millis32 / fireInvSpeedZ.as<uint16_t>();
609
610 uint16_t noise16 = inoise16(cosx << 8, sinx << 8, y << 8, z << 8);
611
612 uint8_t noise_val = noise16 >> 8;
613
614 int8_t subtraction_factor = abs8(height - (max_height - 1)) * 255 /
615 (max_height - 1);
616
617 return qsub8(noise_val, subtraction_factor);
618}
int y
Definition simple.h:93
int x
Definition simple.h:92
uint32_t z[NUM_LAYERS]
Definition Fire2023.h:94
uint16_t scale
Definition Noise.ino:74
int y_speed
UISlider fireScaleXY("Fire Scale", 8, 1, 100, 1)
UISlider fireInvSpeedZ("Fire Inverse SpeedZ", 20, 1, 100, 1)
UISlider fireScaleX("Fire ScaleX",.3, 0.1, 3,.01)
LIB8STATIC_ALWAYS_INLINE int8_t abs8(int8_t i)
Take the absolute value of a signed 8-bit uint8_t.
Definition math8.h:516
LIB8STATIC_ALWAYS_INLINE uint8_t qsub8(uint8_t i, uint8_t j)
Subtract one byte from another, saturating at 0x00.
Definition math8.h:112
uint16_t inoise16(uint32_t x, uint32_t y, uint32_t z, uint32_t t)
16-bit, fixed point implementation of Perlin's noise.
Definition noise.cpp:420
LIB8STATIC uint8_t cos8(uint8_t theta)
Fast 8-bit approximation of cos(x).
Definition trig8.h:280
#define sin8
Platform-independent alias of the fast sin implementation.
Definition trig8.h:230

References abs8(), cos8(), fireInvSpeedZ(), fireScaleX(), fireScaleXY(), inoise16(), qsub8(), scale, sin8, x, y, y_speed, and z.

Referenced by fillFrameBufferFire().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: