FormattedRenderer

Struct FormattedRenderer 

Source
pub struct FormattedRenderer { /* private fields */ }
Expand description

Advanced renderer with additional capabilities.

Implementations§

Source§

impl FormattedRenderer

Source

pub fn new(bg_color: Color) -> FormattedRenderer

Creates a new blank FormattedRenderer. All segments use the same background colour.

Source

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).

Source

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.

Source

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.

Source

pub fn set_bg_color(&mut self, bg_color: Color)

Sets the background color of each component of the formatted output.

Source

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).

Source

pub fn set_scale(&mut self, scale: u32)

Sets the scale of each component in the formatted output.

Source

pub fn get_scale(&self) -> u32

Gets the current scale factor used for draw operations.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, SurfaceRenderer>

Returns an iterator over each renderer, which allows the renderers’ settings to be modified.

Source

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.

Source

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.

Source

pub fn measure_height(&self) -> Result<u32, String>

Returns the height of all content in the formatted string.

Trait Implementations§

Source§

impl IntoIterator for FormattedRenderer

Source§

type Item = SurfaceRenderer

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<SurfaceRenderer>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.