naev 0.12.5
distance_field.c File Reference

Code for generating our distance fields (. More...

#include "edtaa3func.h"
Include dependency graph for distance_field.c:

Go to the source code of this file.

Functions

double * make_distance_mapd (double *data, unsigned int width, unsigned int height, double *vmax)
 Like the original: perform a Euclidean Distance Transform on the input and normalize to [0,1], with a value of 0.5 on the boundary.
float * make_distance_mapbf (unsigned char *img, unsigned int width, unsigned int height, double *vmax)
 Perform a Euclidean Distance Transform on the input and normalize to [0,1], with a value of 0.5 on the boundary.

Detailed Description

Code for generating our distance fields (.

See also
font.c). Based on the corresponding file in https://github.com/rougier/freetype-gl

Definition in file distance_field.c.

Function Documentation

◆ make_distance_mapbf()

float * make_distance_mapbf ( unsigned char * img,
unsigned int width,
unsigned int height,
double * vmax )

Perform a Euclidean Distance Transform on the input and normalize to [0,1], with a value of 0.5 on the boundary.

Parameters
imgPixel values, row-major order.
widthNumber of columns.
heightNumber of rows.
[out]vmaxThe underlying distance value corresponding to +1.0.
Returns
Allocated distance field, values ranging from 0 (innermost) to 1 (outermost). The reason for the inversion (relative to make_distance_mapd and the "signed distance" concept) is so that these can be pasted together in a texture atlas with a buffer of 0.0 values representing "completely outside".

Definition at line 127 of file distance_field.c.

◆ make_distance_mapd()

double * make_distance_mapd ( double * data,
unsigned int width,
unsigned int height,
double * vmax )

Like the original: perform a Euclidean Distance Transform on the input and normalize to [0,1], with a value of 0.5 on the boundary.

Parameters
datawidth*height values, row-major order. Positive values are object pixels. Negative/zero values are background pixels.
widthNumber of columns.
heightNumber of rows.
[out]vmaxThe underlying distance value corresponding to +1.0.
Returns
Allocated distance field, values ranging from 0 (farthest inside) to 1 (greatest distance).

Definition at line 60 of file distance_field.c.