Skip to main content

Label

Struct Label 

Source
pub struct Label<'a> { /* private fields */ }
Expand description

A label (text)

Implementations§

Source§

impl<'a> Label<'a>

Source

pub fn new(font: &'a Font) -> Self

Create a new label

Source

pub fn text(&mut self, s: &str) -> &mut Self

Set the text

Source

pub fn size(&mut self, s: u32) -> &mut Self

Set the font size

Source

pub fn x(&mut self, x: f32) -> &mut Self

Set the x coordinate of the label

Source

pub fn y(&mut self, y: f32) -> &mut Self

Set the y coordinate of the label

Source

pub fn color(&mut self, r: u8, g: u8, b: u8) -> &mut Self

Set the color of the label

Source

pub fn alpha(&mut self, a: u8) -> &mut Self

Set the opacity of the label

Source

pub fn bold(&mut self) -> &mut Self

Make the label bold

Source

pub fn italic(&mut self) -> &mut Self

Make the label italic

Source

pub fn underlined(&mut self) -> &mut Self

Make the label underlined

Source

pub fn go(&mut self, x: f32, y: f32) -> &mut Self

Move the label relative to the current position

Source

pub fn rotate(&mut self, a: f32) -> &mut Self

Rotate the label where a is given in degrees

Source

pub fn step(&mut self, size: f32) -> &mut Self

Step in the current direction

Source

pub fn length_to(&self, (x, y): (f32, f32)) -> f32

Get the length to a given point

Source

pub fn pos(&self) -> (f32, f32)

Get the position of the label

Source

pub fn set(&mut self, (x, y): (f32, f32)) -> &mut Self

Set the position of the label

Source

pub fn draw(&mut self, window: &mut Window)

Draw the label on a window

Auto Trait Implementations§

§

impl<'a> !Send for Label<'a>

§

impl<'a> !Sync for Label<'a>

§

impl<'a> Freeze for Label<'a>

§

impl<'a> RefUnwindSafe for Label<'a>

§

impl<'a> Unpin for Label<'a>

§

impl<'a> UnsafeUnpin for Label<'a>

§

impl<'a> UnwindSafe for Label<'a>

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.