FastLED 3.9.3
Loading...
Searching...
No Matches
noisegen.h
1#pragma once
2
3#include <stdint.h>
4#include "noise.h"
5
6#include "math_macros.h"
7#include "namespace.h"
8
9FASTLED_NAMESPACE_BEGIN
10
11
12// Simple noise generator for 1-d waves. Default values will give good results
13// for most cases.
15 int32_t iteration_scale;
16 unsigned long time_multiplier;
17
18 NoiseGenerator() : iteration_scale(10), time_multiplier(10) {}
19 NoiseGenerator(int32_t itScale, int32_t timeMul) : iteration_scale(itScale), time_multiplier(timeMul) {}
20
21 uint8_t Value(int32_t i, unsigned long time_ms) const {
22 uint32_t input = iteration_scale * i + time_ms * time_multiplier;
23 uint16_t v1 = inoise16(input);
24 return uint8_t(v1 >> 8);
25 }
26
27 int LedValue(int32_t i, unsigned long time_ms) const {
28 int val = Value(i, time_ms);
29 return MAX(0, val - 128) * 2;
30 }
31};
32
33FASTLED_NAMESPACE_END
uint16_t inoise16(uint32_t x, uint32_t y, uint32_t z)
16-bit, fixed point implementation of Perlin's noise.
Definition noise.cpp:378
Functions to generate and fill arrays with noise.