Struct wasm4_sx::Text

source ·
pub struct Text<T: AsRef<[u8]>> { /* private fields */ }
Expand description

A text drawing helper.

Example

use wasm4_sx::*;

#[no_mangle]
fn update() {
    Text::new("Top left")
        .with_horizontal_alignment(TextHorizontalAlignment::Left)
        .with_vertical_alignment(TextVerticalAligment::Top)
        .draw();

    Text::new("Middle center")
        .with_horizontal_alignment(TextHorizontalAlignment::Center)
        .with_vertical_alignment(TextVerticalAligment::Middle)
        .draw();

    Text::new("Bottom right")
        .with_horizontal_alignment(TextHorizontalAlignment::Right)
        .with_vertical_alignment(TextVerticalAligment::Bottom)
        .draw();
}

Implementations§

source§

impl<T: AsRef<[u8]>> Text<T>

source

pub const fn new(value: T) -> Self

Build a new text drawing helper.

source

pub fn with_x(self, x: i32) -> Self

Set the X coordinate.

source

pub fn with_y(self, y: i32) -> Self

Set the Y coordinate.

source

pub fn with_padding_x(self, padding_x: i32) -> Self

Set the X padding.

source

pub fn with_padding_y(self, padding_y: i32) -> Self

Set the Y padding.

source

pub fn with_horizontal_alignment( self, alignment: TextHorizontalAlignment ) -> Self

Set the horizontal alignment.

source

pub fn with_vertical_alignment(self, alignment: TextVerticalAligment) -> Self

Set the vertical alignment.

source

pub fn with_line_separation(self, line_separation: i32) -> Self

Set the line separation value.

source

pub fn draw(self)

Draw the text.

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Text<T>where T: RefUnwindSafe,

§

impl<T> Send for Text<T>where T: Send,

§

impl<T> Sync for Text<T>where T: Sync,

§

impl<T> Unpin for Text<T>where T: Unpin,

§

impl<T> UnwindSafe for Text<T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.