FastLED 3.9.7
Loading...
Searching...
No Matches
noisegen.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <stdint.h>
7#include "noise.h"
8
9#include "fl/math_macros.h"
10#include "fl/namespace.h"
11
13
14
15// Simple noise generator for 1-d waves. Default values will give good results
16// for most cases.
18 int32_t iteration_scale;
19 unsigned long time_multiplier;
20
21 NoiseGenerator() : iteration_scale(10), time_multiplier(10) {}
22 NoiseGenerator(int32_t itScale, int32_t timeMul) : iteration_scale(itScale), time_multiplier(timeMul) {}
23
24 uint8_t Value(int32_t i, unsigned long time_ms) const {
25 uint32_t input = iteration_scale * i + time_ms * time_multiplier;
26 uint16_t v1 = inoise16(input);
27 return uint8_t(v1 >> 8);
28 }
29
30 int LedValue(int32_t i, unsigned long time_ms) const {
31 int val = Value(i, time_ms);
32 return MAX(0, val - 128) * 2;
33 }
34};
35
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
Implements the FastLED namespace macros.
#define FASTLED_NAMESPACE_END
End of the FastLED namespace.
Definition namespace.h:16
#define FASTLED_NAMESPACE_BEGIN
Start of the FastLED namespace.
Definition namespace.h:14
Functions to generate and fill arrays with noise.