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

Function renderSDF

MyGUIEngine/src/msdfgen/core/render-sdf.cpp:15–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13}
14
15void renderSDF(const BitmapSection<float, 1> &output, const BitmapConstSection<float, 1> &sdf, Range sdfPxRange, float sdThreshold) {
16 Vector2 scale((double) sdf.width/output.width, (double) sdf.height/output.height);
17 if (sdfPxRange.lower == sdfPxRange.upper) {
18 for (int y = 0; y < output.height; ++y) {
19 for (int x = 0; x < output.width; ++x) {
20 float sd;
21 interpolate(&sd, sdf, scale*Point2(x+.5, y+.5));
22 *output(x, y) = float(sd >= sdThreshold);
23 }
24 }
25 } else {
26 sdfPxRange *= (double) (output.width+output.height)/(sdf.width+sdf.height);
27 DistanceMapping distanceMapping = DistanceMapping::inverse(sdfPxRange);
28 float sdBias = .5f-sdThreshold;
29 for (int y = 0; y < output.height; ++y) {
30 for (int x = 0; x < output.width; ++x) {
31 float sd;
32 interpolate(&sd, sdf, scale*Point2(x+.5, y+.5));
33 *output(x, y) = distVal(sd+sdBias, distanceMapping);
34 }
35 }
36 }
37
38}
39
40void renderSDF(const BitmapSection<float, 3> &output, const BitmapConstSection<float, 1> &sdf, Range sdfPxRange, float sdThreshold) {
41 Vector2 scale((double) sdf.width/output.width, (double) sdf.height/output.height);

Callers 1

mainFunction · 0.85

Calls 3

interpolateFunction · 0.85
distValFunction · 0.85
medianFunction · 0.70

Tested by

no test coverage detected