| 13 | } |
| 14 | |
| 15 | void 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 | |
| 40 | void 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); |
no test coverage detected