FastLED 3.10.8
Loading...
Searching...
No Matches

◆ noiseCylinderHSV16()

HSV16 fl::noiseCylinderHSV16 ( float angle,
float height,
u32 time,
float radius = 1.0f )

Cylinder noise functions - sample three z-slices for independent component evolution.

Generate HSV16 noise for a cylinder pattern.

Samples three z-slices of 3D Perlin noise (at time, time+0x10000, time+0x20000) to create independent hue, saturation, and value components. Maps the angle around the circumference using sin/cos, and samples height directly.

Parameters
anglePosition around the cylinder (radians, 0 to 2π)
heightVertical position on the cylinder
timeAnimation time parameter
radiusNoise zoom level (level of detail). Larger values = coarser pattern, smaller = more detail (default 1.0)
Returns
HSV16 color with 16-bit components

Definition at line 167 of file noise.cpp.hpp.

167 {
168 // Convert cylindrical coordinates to cartesian
169 // angle: azimuth around cylinder (0 to 2π)
170 // height: vertical position (used directly)
171 // x = cos(angle)
172 // y = sin(angle)
173 // z = height
174 float x = fl::cosf(angle);
175 float y = fl::sinf(angle);
176
177 // Map sin/cos values from [-1, 1] to [0, 0xFFFF]
178 // This ensures positive values for uint32_t conversion
179 u32 nx = static_cast<u32>((x + 1.0f) * 0.5f * radius * 0xffff);
180 u32 ny = static_cast<u32>((y + 1.0f) * 0.5f * radius * 0xffff);
181 u32 nz = static_cast<u32>(height * radius * 0xffff);
182
183 // Sample three different t-slices for H, S, V components
184 // Using offsets 0x0, 0x10000, 0x20000 to separate them in noise space
185 u16 h_raw = inoise16(nx, ny, nz, time);
186 u16 s_raw = inoise16(nx, ny, nz, time + 0x10000);
187 u16 v_raw = inoise16(nx, ny, nz, time + 0x20000);
188
189 // Rescale from observed noise range to full 0-65535 range using global extents
190 u16 h = rescaleNoiseValue16(h_raw);
191 u16 s = rescaleNoiseValue16(s_raw);
192 u16 v = rescaleNoiseValue16(v_raw);
193
194 return HSV16(h, s, v);
195}
fl::u16 inoise16(fl::u32 x, fl::u32 y, fl::u32 z, fl::u32 t) FL_NO_EXCEPT
u8 u8 height
Definition blur.h:186
float sinf(float value) FL_NO_EXCEPT
Definition math.h:360
fl::u64 time() FL_NO_EXCEPT
Alias for millis64() - returns 64-bit millisecond time.
Definition chrono.h:346
FASTLED_FORCE_INLINE u16 rescaleNoiseValue16(u16 raw_value) FL_NO_EXCEPT
Rescale raw inoise16() output to full 16-bit range [0, 65535] Curries in the global NOISE16_EXTENT_MI...
Definition noise.cpp.hpp:22
float cosf(float value) FL_NO_EXCEPT
Definition math.h:366

References cosf(), FL_NO_EXCEPT, height, inoise16(), rescaleNoiseValue16(), sinf(), time(), x, and y.

Referenced by noiseCylinderHSV8().

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