MCPcopy Create free account
hub / github.com/MyGUI/mygui / interpolate

Function interpolate

MyGUIEngine/src/msdfgen/core/bitmap-interpolation.hpp:11–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10template <typename T, int N>
11inline void interpolate(T *output, const BitmapConstSection<T, N> &bitmap, Point2 pos) {
12 pos.x = clamp(pos.x, double(bitmap.width));
13 pos.y = clamp(pos.y, double(bitmap.height));
14 pos -= .5;
15 int l = (int) floor(pos.x);
16 int b = (int) floor(pos.y);
17 int r = l+1;
18 int t = b+1;
19 double lr = pos.x-l;
20 double bt = pos.y-b;
21 l = clamp(l, bitmap.width-1), r = clamp(r, bitmap.width-1);
22 b = clamp(b, bitmap.height-1), t = clamp(t, bitmap.height-1);
23 for (int i = 0; i < N; ++i)
24 output[i] = mix(mix(bitmap(l, b)[i], bitmap(r, b)[i], lr), mix(bitmap(l, t)[i], bitmap(r, t)[i], lr), bt);
25}
26
27}

Callers 2

evaluateMethod · 0.85
renderSDFFunction · 0.85

Calls 2

clampFunction · 0.85
mixFunction · 0.85

Tested by

no test coverage detected