| 64 | /////////////////////////////////////////// |
| 65 | |
| 66 | tex_t sdf_create_tex(int32_t width, int32_t height, float (*sdf)(vec2 pt), float scale) { |
| 67 | color32 *data = sk_malloc_t(color32, width * height); |
| 68 | float center_x = width / 2.0f - 0.5f; |
| 69 | float center_y = height / 2.0f - 0.5f; |
| 70 | for (int32_t y = 0; y < height; y++) { |
| 71 | int32_t yoff = y * width; |
| 72 | for (int32_t x = 0; x < width; x++) { |
| 73 | float dist = sdf({ x - center_x, y - center_y }); |
| 74 | float lerp = 1-math_saturate(dist * scale); |
| 75 | |
| 76 | data[x + yoff] = {255,255,255,(uint8_t)(lerp * 255)}; |
| 77 | } |
| 78 | } |
| 79 | return tex_create_color32(data, width, height, false); |
| 80 | } |
| 81 | |
| 82 | /////////////////////////////////////////// |
| 83 |
no test coverage detected