pub fn clamp_to_u8(sdf: &[f64], cutoff: f64) -> Vec<u8> {
    assert!(
        cutoff > 0.0 && cutoff < 1.0,
        "Cutoff values must be between 0 and 1"
    );
    sdf.iter()
        .map(|v| {
            // Map the values back into the single byte integer range.
            // Note: casting from a float to an integer performs a saturating
            // cast in Rust, removing the need for special logic.
            // See https://doc.rust-lang.org/nomicon/casts.html.
            (255.0 - 255.0 * (v + cutoff)) as u8
        })
        .collect()
}
/// 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.
///
/// # Panics
///
/// The `cutoff` value must be in the range (0, 1). Values outside this range make no sense and
/// will cause a panic.
Compresses a Vec into a Vec 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.
Compresses a Vec into a Vec 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 .
pub fn clamp_to_u8(sdf: &[f64], cutoff: f64) -> Vec<u8> {
    assert!(
        cutoff > 0.0 && cutoff < 1.0,
        "Cutoff values must be between 0 and 1"
    );
    sdf.iter()
        .map(|v| {
            // Map the values back into the single byte integer range.
            // Note: casting from a float to an integer performs a saturating
            // cast in Rust, removing the need for special logic.
            // See https://doc.rust-lang.org/nomicon/casts.html.
            (255.0 - 255.0 * (v + cutoff)) as u8
        })
        .collect()
}
pub fn clamp_to_u8 ( sdf : & [ f64 ] , cutoff : f64 ) -> Vec < u8 > { assert ! ( cutoff 0.0 cutoff 1.0 " " ) ; sdf . iter ( ) . map ( | v | { // Map the values back into the single byte integer range. // Note: casting from a float to an integer performs a saturating // cast in Rust, removing the need for special logic. // See https://doc.rust-lang.org/nomicon/casts.html. ( 255.0 - 255.0 * ( v + cutoff ) ) as u8 } ) . collect ( ) }
Compresses a Vec<f64> into a Vec<u8> for efficiency.
Compresses a Vec<f64 > into a Vec<u8 > for efficiency .
sdf
&[f64]
cutoff
f64
sdf
&[f64]
cutoff
f64
panics
The `cutoff` value must be in the range (0, 1). Values outside this range make no sense and
will cause a panic.
The ` cutoff ` value must be in the range ( 0 1 ) . Values outside this range make no sense and will cause a panic .