pub struct TextFragment {
pub text: String,
pub color: Option<Color>,
pub font: Option<Font>,
pub scale: Option<PxScale>,
}Expand description
A piece of text with optional color, font and font scale information.
Drawing text generally involves one or more of these.
These options take precedence over any similar field/argument.
Implements From for char, &str, String and
(String, Font, PxScale).
Fields§
§text: StringText string itself.
color: Option<Color>Fragment’s color, defaults to text’s color.
font: Option<Font>Fragment’s font, defaults to text’s font.
scale: Option<PxScale>Fragment’s scale, defaults to text’s scale.
Implementations§
Source§impl TextFragment
impl TextFragment
Sourcepub fn color<C: Into<Color>>(self, color: C) -> TextFragment
pub fn color<C: Into<Color>>(self, color: C) -> TextFragment
Set fragment’s color, overrides text’s color.
Sourcepub fn font(self, font: Font) -> TextFragment
pub fn font(self, font: Font) -> TextFragment
Set fragment’s font, overrides text’s font.
Sourcepub fn scale<S: Into<PxScale>>(self, scale: S) -> TextFragment
pub fn scale<S: Into<PxScale>>(self, scale: S) -> TextFragment
Set fragment’s scale, overrides text’s scale. Default is 16.0
Trait Implementations§
Source§impl Clone for TextFragment
impl Clone for TextFragment
Source§fn clone(&self) -> TextFragment
fn clone(&self) -> TextFragment
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TextFragment
impl Debug for TextFragment
Source§impl Default for TextFragment
impl Default for TextFragment
Source§impl<'a> From<&'a str> for TextFragment
impl<'a> From<&'a str> for TextFragment
Source§fn from(text: &'a str) -> TextFragment
fn from(text: &'a str) -> TextFragment
Converts to this type from the input type.
Source§impl<T> From<(T, Font, f32)> for TextFragmentwhere
T: Into<TextFragment>,
impl<T> From<(T, Font, f32)> for TextFragmentwhere
T: Into<TextFragment>,
Source§impl From<String> for TextFragment
impl From<String> for TextFragment
Source§fn from(text: String) -> TextFragment
fn from(text: String) -> TextFragment
Converts to this type from the input type.
Source§impl From<char> for TextFragment
impl From<char> for TextFragment
Source§fn from(ch: char) -> TextFragment
fn from(ch: char) -> TextFragment
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for TextFragment
impl RefUnwindSafe for TextFragment
impl Send for TextFragment
impl Sync for TextFragment
impl Unpin for TextFragment
impl UnwindSafe for TextFragment
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more