MCPcopy Create free account
hub / github.com/FastLED/FastLED / noiseRingHSV16

Function noiseRingHSV16

src/fl/gfx/noise/noise.cpp.hpp:27–49  ·  view source on GitHub ↗

Ring noise functions - sample three z-slices for independent component evolution

Source from the content-addressed store, hash-verified

25
26/// Ring noise functions - sample three z-slices for independent component evolution
27HSV16 noiseRingHSV16(float angle, u32 time, float radius) {
28 // Convert angle to cartesian coordinates
29 float x = fl::cosf(angle);
30 float y = fl::sinf(angle);
31
32 // Map sin/cos values from [-1, 1] to [0, 0xFFFF]
33 // This ensures positive values for uint32_t conversion
34 u32 nx = static_cast<u32>((x + 1.0f) * 0.5f * radius * 0xffff);
35 u32 ny = static_cast<u32>((y + 1.0f) * 0.5f * radius * 0xffff);
36
37 // Sample three different z-slices for H, S, V components
38 // Using offsets 0x0, 0x10000, 0x20000 to separate them in noise space
39 u16 h_raw = inoise16(nx, ny, time);
40 u16 s_raw = inoise16(nx, ny, time + 0x10000);
41 u16 v_raw = inoise16(nx, ny, time + 0x20000);
42
43 // Rescale from observed noise range to full 0-65535 range using global extents
44 u16 h = rescaleNoiseValue16(h_raw);
45 u16 s = rescaleNoiseValue16(s_raw);
46 u16 v = rescaleNoiseValue16(v_raw);
47
48 return HSV16(h, s, v);
49}
50
51CHSV noiseRingHSV8(float angle, u32 time, float radius) {
52 fl::HSV16 hsv16 = noiseRingHSV16(angle, time, radius);

Callers 2

noiseRingHSV8Function · 0.85
FL_TEST_FILEFunction · 0.85

Calls 5

cosfFunction · 0.85
sinfFunction · 0.85
inoise16Function · 0.85
rescaleNoiseValue16Function · 0.85
HSV16Class · 0.50

Tested by

no test coverage detected