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

Method pnoise2d_raw

src/fl/math/noise/perlin_s16x16.cpp.hpp:34–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34fl::i32 perlin_s16x16::pnoise2d_raw(fl::i32 fx_raw, fl::i32 fy_raw,
35 const fl::i32 *fade_lut,
36 const fl::u8 *perm) {
37 int X, Y;
38 fl::i32 x, y;
39 floor_frac(fx_raw, X, x);
40 floor_frac(fy_raw, Y, y);
41 X &= 255;
42 Y &= 255;
43
44 fl::i32 u = fade(x, fade_lut);
45 fl::i32 v = fade(y, fade_lut);
46
47 int A = perm[X & 255] + Y;
48 int AA = perm[A & 255];
49 int AB = perm[(A + 1) & 255];
50 int B = perm[(X + 1) & 255] + Y;
51 int BA = perm[B & 255];
52 int BB = perm[(B + 1) & 255];
53
54 fl::i32 result = lerp(v,
55 lerp(u, grad(perm[AA & 255], x, y),
56 grad(perm[BA & 255], x - HP_ONE, y)),
57 lerp(u, grad(perm[AB & 255], x, y - HP_ONE),
58 grad(perm[BB & 255], x - HP_ONE, y - HP_ONE)));
59
60 return result >> (HP_BITS - fl::s16x16::FRAC_BITS);
61}
62
63 void perlin_s16x16::floor_frac(fl::i32 fp16, int &ifloor,
64 fl::i32 &frac24) {

Callers

nothing calls this directly

Calls 3

fadeFunction · 0.85
lerpFunction · 0.50
gradFunction · 0.50

Tested by

no test coverage detected