Struct sdf_glyph_renderer::BitmapGlyph
source · pub struct BitmapGlyph { /* private fields */ }
Expand description
A raw bitmap containing only the alpha channel.
Implementations§
source§impl BitmapGlyph
impl BitmapGlyph
sourcepub fn new(
alpha: Vec<u8>,
width: usize,
height: usize,
buffer: usize
) -> Result<BitmapGlyph, SdfGlyphError>
pub fn new( alpha: Vec<u8>, width: usize, height: usize, buffer: usize ) -> Result<BitmapGlyph, SdfGlyphError>
Creates a new bitmap from scratch.
This constructor is useful when you already have a buffered glyph. If you have the alpha
bitmap but still need to buffer it (what you expect from most font renderers, for example),
use Self::from_unbuffered()
instead.
The dimensions provided is expected to describe the input data.
sourcepub fn from_unbuffered(
alpha: &[u8],
width: usize,
height: usize,
buffer: usize
) -> Result<BitmapGlyph, SdfGlyphError>
pub fn from_unbuffered( alpha: &[u8], width: usize, height: usize, buffer: usize ) -> Result<BitmapGlyph, SdfGlyphError>
Creates a new bitmap from a raw data source, buffered by a given amount.
Most SDF glyphs are buffered a bit so that the outer edges can be properly captured. This constructor does the buffering for you.
The dimensions provided is expected to describe the input data.
sourcepub fn render_sdf(&self, radius: usize) -> Vec<f64>
pub fn render_sdf(&self, radius: usize) -> Vec<f64>
Render a signed distance field for the given bitmap, recording distances
out to radius
pixels from the shape outline (the rest will be clamped).
The range of the output field is [-1.0, 1.0], normalised to units of radius
.
Trait Implementations§
source§impl Debug for BitmapGlyph
impl Debug for BitmapGlyph
source§impl PartialEq for BitmapGlyph
impl PartialEq for BitmapGlyph
source§fn eq(&self, other: &BitmapGlyph) -> bool
fn eq(&self, other: &BitmapGlyph) -> bool
self
and other
values to be equal, and is used
by ==
.