pub struct FormattedRenderer { /* private fields */ }
Expand description
Advanced renderer with additional capabilities.
Implementations§
Source§impl FormattedRenderer
impl FormattedRenderer
Sourcepub fn new(bg_color: Color) -> FormattedRenderer
pub fn new(bg_color: Color) -> FormattedRenderer
Creates a new blank FormattedRenderer
. All segments use the same
background colour.
Sourcepub fn add_text(&mut self, text: &str, color: Color, bold: bool, italic: bool)
pub fn add_text(&mut self, text: &str, color: Color, bold: bool, italic: bool)
Adds a string literal, which cannot be modified once added (i.e. you’ll
need to create a new FormattedRenderer
instead).
Sourcepub fn add_var(&mut self, name: &str, color: Color, bold: bool, italic: bool)
pub fn add_var(&mut self, name: &str, color: Color, bold: bool, italic: bool)
Adds a named variable, which can have its value and changed after creation.
Sourcepub fn set_var(&mut self, name: &str, value: &str)
pub fn set_var(&mut self, name: &str, value: &str)
Sets or modifies the value of an already added variable. If the variable referenced does not exist, nothing happens.
Sourcepub fn set_bg_color(&mut self, bg_color: Color)
pub fn set_bg_color(&mut self, bg_color: Color)
Sets the background color of each component of the formatted output.
Sourcepub fn get_bg_color(&self) -> Color
pub fn get_bg_color(&self) -> Color
Returns the default background colour for each rendered section (unless
it’s been changed by modifying a renderer’s background colour through
the iter_mut
method).
Sourcepub fn set_scale(&mut self, scale: u32)
pub fn set_scale(&mut self, scale: u32)
Sets the scale of each component in the formatted output.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, SurfaceRenderer>
pub fn iter_mut(&mut self) -> IterMut<'_, SurfaceRenderer>
Returns an iterator over each renderer, which allows the renderers’ settings to be modified.
Sourcepub fn draw<'a>(&self) -> Result<Surface<'a>, String>
pub fn draw<'a>(&self) -> Result<Surface<'a>, String>
Sequentially draws each literal and variable, using its associated renderer, and linearly appends the output surfaces.
Sourcepub fn measure_width(&self) -> Result<u32, String>
pub fn measure_width(&self) -> Result<u32, String>
Measures the width of all of the contained text, including variable values, taking into consideration the formatting of each section.
Sourcepub fn measure_height(&self) -> Result<u32, String>
pub fn measure_height(&self) -> Result<u32, String>
Returns the height of all content in the formatted string.