pub struct Text<'a> {
pub coords: (usize, usize),
pub font: &'a Font,
pub text: String,
pub style: TextStyle,
pub character_size: (usize, &'a str),
}
Expand description
A text drawable on a Canvas. Multiline (\n) works only when using a character size in px.
Fields§
§coords: (usize, usize)
The coords of the text in px.
font: &'a Font
The font of the text.
text: String
The text.
style: TextStyle
The style of the text (bold/italic…)
character_size: (usize, &'a str)
The character_size. example: (14, “px”)
Implementations§
Source§impl<'a> Text<'a>
impl<'a> Text<'a>
Sourcepub fn new_with_text_and_coords(
font: &'a Font,
text: String,
coords: (usize, usize),
) -> Text<'a>
pub fn new_with_text_and_coords( font: &'a Font, text: String, coords: (usize, usize), ) -> Text<'a>
Create a new text with some default values.
Sourcepub fn new_with_options(
font: &'a Font,
text: String,
coords: (usize, usize),
style: TextStyle,
character_size: (usize, &'a str),
) -> Text<'a>
pub fn new_with_options( font: &'a Font, text: String, coords: (usize, usize), style: TextStyle, character_size: (usize, &'a str), ) -> Text<'a>
Create a new text with no default value.
Sourcepub fn get_width(&self, canvas: &mut Canvas) -> f64
pub fn get_width(&self, canvas: &mut Canvas) -> f64
Get the width of the text Needs a mutable reference to a canvas
Sourcepub fn get_height(&self) -> usize
pub fn get_height(&self) -> usize
Get the width of the text. Works only for font size specified using a value in px.
Trait Implementations§
Source§impl<'a> Drawable for Text<'a>
impl<'a> Drawable for Text<'a>
Source§fn draw_on_canvas(&self, canvas: &mut Canvas)
fn draw_on_canvas(&self, canvas: &mut Canvas)
This method is called by the draw method.
Auto Trait Implementations§
impl<'a> Freeze for Text<'a>
impl<'a> RefUnwindSafe for Text<'a>
impl<'a> Send for Text<'a>
impl<'a> Sync for Text<'a>
impl<'a> Unpin for Text<'a>
impl<'a> UnwindSafe for Text<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more