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

Method init

src/fl/fx/2d/flowfield.cpp.hpp:60–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58// ---------------------------------------------------------------------------
59
60void FlowFieldFloat::Perlin2D::init(u32 seed) {
61 u8 p[256];
62 for (int i = 0; i < 256; i++)
63 p[i] = (u8)i;
64 u32 s = seed;
65 for (int i = 255; i > 0; i--) {
66 s = s * 1664525u + 1013904223u;
67 int j = (int)((s >> 16) % (u32)(i + 1));
68 u8 tmp = p[i];
69 p[i] = p[j];
70 p[j] = tmp;
71 }
72 for (int i = 0; i < 256; i++) {
73 perm[i] = p[i];
74 perm[i + 256] = p[i];
75 }
76}
77
78float FlowFieldFloat::Perlin2D::noise(float x, float y) const {
79 int xi = ((int)floorf(x)) & 255;

Callers 2

FlowFieldFloatMethod · 0.45
FlowFieldFPMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected