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

Function Interp

examples/LuminescentGrand/shared/ApproximatingFunction.h:54–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52
53template <typename KeyT, typename ValT>
54inline ValT Interp(const KeyT& k, const InterpData<KeyT, ValT>* array, const int n) {
55 if (n < 1) {
56 return ValT(0);
57 }
58
59 int low_idx = -1;
60 int high_idx = -1;
61
62 SelectInterpPoints<KeyT, ValT>(k, array, n, &low_idx, &high_idx);
63
64 if (low_idx == high_idx) {
65 return array[low_idx].val;
66 }
67
68 const InterpData<KeyT, ValT>* curr = &array[low_idx];
69 const InterpData<KeyT, ValT>* next = &array[high_idx];
70 // map(...) only works on integers. MapT<> is the same thing but it works on
71 // all datatypes.
72 return MapT<KeyT, ValT>(k, curr->key, next->key, curr->val, next->val);
73}
74
75#endif // APPROXIMATING_FUNCTION_H_

Callers 4

LuminanceDecayFunction · 0.85
AttackRemapFactorFunction · 0.85
MapDecayTimeFunction · 0.85
ToBrightnessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected