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

◆ getPaletteIndex()

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

Definition at line 75 of file FireCylinder.ino.

76 {
77 // get palette index
78 uint16_t scale = scaleXY.as<uint16_t>();
79 float xf = (float)width / (float)max_width;
80 uint8_t x = (uint8_t)(xf * 255);
81 uint32_t cosx = cos8(x);
82 uint32_t sinx = sin8(x);
83 float trig_scale = scale * scaleX.value();
84 cosx *= trig_scale;
85 sinx *= trig_scale;
86 uint32_t y = height * scale + y_speed; // swapped: now using height
87 uint16_t z = millis32 / invSpeedZ.as<uint16_t>();
88
89 uint16_t noise16 = inoise16(cosx << 8, sinx << 8, y << 8, 0);
90 uint8_t noise_val = noise16 >> 8;
91 int8_t subtraction_factor = abs8(height - (max_height - 1)) * 255 /
92 (max_height - 1); // swapped: now using height
93 return qsub8(noise_val, subtraction_factor);
94}
uint32_t z[NUM_LAYERS]
Definition Fire2023.ino:82
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
UISlider scaleXY("Scale", 8, 1, 100, 1)
UISlider invSpeedZ("Inverse SpeedZ", 20, 1, 100, 1)
UISlider scaleX("ScaleX",.3, 0.1, 3,.01)
UISlider scale("Scale", 4,.1, 4,.1)
int y_speed
LIB8STATIC_ALWAYS_INLINE int8_t abs8(int8_t i)
Take the absolute value of a signed 8-bit uint8_t.
Definition math8.h:500
LIB8STATIC_ALWAYS_INLINE uint8_t qsub8(uint8_t i, uint8_t j)
Subtract one byte from another, saturating at 0x00.
Definition math8.h:103
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:466
LIB8STATIC uint8_t cos8(uint8_t theta)
Fast 8-bit approximation of cos(x).
Definition trig8.h:266
#define sin8
Platform-independent alias of the fast sin implementation.
Definition trig8.h:216

References abs8(), cos8(), inoise16(), invSpeedZ, qsub8(), scale, scaleX, scaleXY, sin8, x, y, y_speed, and z.

Referenced by loop().

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