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

Function grad16

src/noise.cpp.hpp:116–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114} // namespace noise_detail
115
116static fl::i16 inline __attribute__((always_inline)) grad16(fl::u8 hash, fl::i16 x, fl::i16 y, fl::i16 z) {
117#if 0
118 switch(hash & 0xF) {
119 case 0: return (( x) + ( y))>>1;
120 case 1: return ((-x) + ( y))>>1;
121 case 2: return (( x) + (-y))>>1;
122 case 3: return ((-x) + (-y))>>1;
123 case 4: return (( x) + ( z))>>1;
124 case 5: return ((-x) + ( z))>>1;
125 case 6: return (( x) + (-z))>>1;
126 case 7: return ((-x) + (-z))>>1;
127 case 8: return (( y) + ( z))>>1;
128 case 9: return ((-y) + ( z))>>1;
129 case 10: return (( y) + (-z))>>1;
130 case 11: return ((-y) + (-z))>>1;
131 case 12: return (( y) + ( x))>>1;
132 case 13: return ((-y) + ( z))>>1;
133 case 14: return (( y) + (-x))>>1;
134 case 15: return ((-y) + (-z))>>1;
135 }
136#else
137 hash = hash&15;
138 fl::i16 u = hash<8?x:y;
139 fl::i16 v = hash<4?y:hash==12||hash==14?x:z;
140 if(hash&1) { u = -u; }
141 if(hash&2) { v = -v; }
142
143 return AVG15(u,v);
144#endif
145}
146
147static fl::i16 inline __attribute__((always_inline)) grad16(fl::u8 hash, fl::i16 x, fl::i16 y) {
148 hash = hash & 7;

Callers 1

inoise16_rawFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected