pub fn clamp_to_u8(sdf: &[f64], cutoff: f64) -> Result<Vec<u8>, SdfGlyphError>
Expand description

Compresses a Vec<f64> into a Vec<u8> for efficiency.

The highest cutoff percent of values in the range (0-255) will be used to encode negative values (points inside the glyph). This can be tuned based on the intended application.

The cutoff value must be in the range (0, 1) - non-inclusive on both sides. Values outside this range make no sense and will result in an error.