| 78 | } |
| 79 | |
| 80 | T interp16(u16 alpha) FL_NOEXCEPT { |
| 81 | if (length == 0) |
| 82 | return T(); |
| 83 | if (alpha == 0) |
| 84 | return data[0]; |
| 85 | if (alpha == 65535) |
| 86 | return data[length - 1]; |
| 87 | |
| 88 | // treat alpha/65535 as fraction, scale to [0..length-1] |
| 89 | u32 maxIndex = length - 1; |
| 90 | u32 pos = u32(alpha) * maxIndex; // numerator |
| 91 | u32 idx0 = pos / 65535; // floor(position) |
| 92 | u32 idx1 = idx0 < maxIndex ? idx0 + 1 : maxIndex; |
| 93 | u16 blend = pos % 65535; // fractional part |
| 94 | |
| 95 | const T &a = data[idx0]; |
| 96 | const T &b = data[idx1]; |
| 97 | // a + (b-a) * blend/65535 |
| 98 | return a + (b - a) * blend / 65535; |
| 99 | } |
| 100 | |
| 101 | private: |
| 102 | fl::unique_ptr<T> mDataHandle; |
no test coverage detected