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
9
FASTLED_NAMESPACE_BEGIN
10
11
12
// Simple noise generator for 1-d waves. Default values will give good results
13
// for most cases.
14
struct
NoiseGenerator
{
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
33
FASTLED_NAMESPACE_END
inoise16
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
noise.h
Functions to generate and fill arrays with noise.
NoiseGenerator
Definition
noisegen.h:14
src
noisegen.h
Generated on Thu Nov 14 2024 00:00:34 for FastLED by
1.11.0