Struct components::engine::d2::display::TextSprite
source · [−]pub struct TextSprite {
pub inner: Sprite,
pub wrap_width: AnimatedFloat,
pub letter_spacing: AnimatedFloat,
pub line_spacing: AnimatedFloat,
/* private fields */
}
Expand description
A sprite that displays a line of text using a bitmap font.
Fields
inner: Sprite
wrap_width: AnimatedFloat
The maximum available width of this text before word wrapping to a new line. Defaults to 0 (no word wrapping).
letter_spacing: AnimatedFloat
Additional horizontal space to apply between letters, in pixels. Defaults to 0. Positive values make text look “looser”, negative values look “tighter”.
line_spacing: AnimatedFloat
Additional vertical space to apply between lines, in pixels. Defaults to 0. Positive values make lines look “looser”, negative values look “tighter”.
Implementations
sourceimpl TextSprite
impl TextSprite
pub fn new(font: Font, text: Option<String>) -> TextSprite
pub fn draw(&mut self, gfx: &Box<dyn Graphics + 'static, Global>)
pub fn natural_width(&mut self) -> f32
pub fn natural_height(&mut self) -> f32
pub fn contains_local(&mut self, local_x: f32, local_y: f32) -> bool
sourcepub fn set_wrap_width(&mut self, wrap_width: f32) -> &TextSprite
pub fn set_wrap_width(&mut self, wrap_width: f32) -> &TextSprite
Chainable convenience method to set the wrap width. @returns This instance, for chaining.
sourcepub fn set_letter_spacing(&mut self, letter_spacing: f32) -> &TextSprite
pub fn set_letter_spacing(&mut self, letter_spacing: f32) -> &TextSprite
Chainable convenience method to set the letter spacing. @returns This instance, for chaining.
sourcepub fn set_line_spacing(&mut self, line_spacing: f32) -> &TextSprite
pub fn set_line_spacing(&mut self, line_spacing: f32) -> &TextSprite
Chainable convenience method to set the line spacing. @returns This instance, for chaining.
pub fn text(&self) -> Option<String>
pub fn set_text(&mut self, text: Option<String>)
pub fn font(&self) -> Font
pub fn set_font(&mut self, font: Font)
pub fn align(&self) -> TextAlign
pub fn set_align(&mut self, align: TextAlign)
pub fn on_update(&mut self, dt: f32)
Trait Implementations
sourceimpl AsRef<Sprite> for TextSprite
impl AsRef<Sprite> for TextSprite
sourceimpl Clone for TextSprite
impl Clone for TextSprite
sourcefn clone(&self) -> TextSprite
fn clone(&self) -> TextSprite
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for TextSprite
impl Debug for TextSprite
sourceimpl Default for TextSprite
impl Default for TextSprite
sourcefn default() -> TextSprite
fn default() -> TextSprite
Returns the “default value” for a type. Read more
sourceimpl EntityManager<TextSprite> for Entity
impl EntityManager<TextSprite> for Entity
fn get(&self) -> Option<TextSprite>
Auto Trait Implementations
impl !RefUnwindSafe for TextSprite
impl !Send for TextSprite
impl !Sync for TextSprite
impl Unpin for TextSprite
impl !UnwindSafe for TextSprite
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<'a, T, C, M> Inspect<'a, C, &'a C, M> for T
impl<'a, T, C, M> Inspect<'a, C, &'a C, M> for T
impl<'a, T, C, M> Inspect<'a, C, &'a mut C, M> for T
impl<'a, T, C, M> Inspect<'a, C, &'a mut C, M> for T
impl<Fr, To> IntoColor<To> for Fr where
To: FromColor<Fr>,
impl<Fr, To> IntoColor<To> for Fr where
To: FromColor<Fr>,
fn into_color(self) -> To
fn into_color(self) -> To
Convert into color
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> SetParameter for T
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
Sets value
as a parameter of self
.