| 61 | } |
| 62 | |
| 63 | CRGB noiseRingCRGB(float angle, u32 time, float radius) { |
| 64 | // Convert angle to cartesian coordinates |
| 65 | float x = fl::cosf(angle); |
| 66 | float y = fl::sinf(angle); |
| 67 | |
| 68 | // Map sin/cos values from [-1, 1] to [0, 0xFFFF] |
| 69 | // This ensures positive values for uint32_t conversion |
| 70 | u32 nx = static_cast<u32>((x + 1.0f) * 0.5f * radius * 0xffff); |
| 71 | u32 ny = static_cast<u32>((y + 1.0f) * 0.5f * radius * 0xffff); |
| 72 | |
| 73 | // Sample three different z-slices for R, G, B components (direct RGB) |
| 74 | // Using offsets 0x0, 0x10000, 0x20000 to separate them in noise space |
| 75 | u16 r16_raw = inoise16(nx, ny, time); |
| 76 | u16 g16_raw = inoise16(nx, ny, time + 0x10000); |
| 77 | u16 b16_raw = inoise16(nx, ny, time + 0x20000); |
| 78 | |
| 79 | // Rescale from observed noise range to full 0-65535 range using global extents |
| 80 | u16 r16 = rescaleNoiseValue16(r16_raw); |
| 81 | u16 g16 = rescaleNoiseValue16(g16_raw); |
| 82 | u16 b16 = rescaleNoiseValue16(b16_raw); |
| 83 | |
| 84 | // Scale down to 8-bit |
| 85 | u8 r = r16 >> 8; |
| 86 | u8 g = g16 >> 8; |
| 87 | u8 b = b16 >> 8; |
| 88 | |
| 89 | return CRGB(r, g, b); |
| 90 | } |
| 91 | |
| 92 | |
| 93 | /// Sphere noise functions - sample three z-slices for independent component evolution |
no test coverage detected