Skip to main content

TextDraw

Struct TextDraw 

Source
#[non_exhaustive]
pub struct TextDraw { pub font: Handle<Font>, pub position: Vec2, pub pivot: Vec2, pub layout: TextLayout, pub color: Color, pub glyphs: GlyphMode, pub layer: u8, pub sort: SortMode, }
Expand description

A text to draw in the world, in a Font: what TextList::push takes with the text itself.

Its glyphs are drawn as sprites of its layer at its depth, unrotated, each glyph’s corner on a whole virtual pixel: grouped by page, and in the order its characters are laid out on each, so that the glyphs of a font of two pages that overlap may draw out of their order.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§font: Handle<Font>

The font.

§position: Vec2

Where the pivot is in the world.

§pivot: Vec2

The point of the text’s block at position, normalized over the block Font::measure gives: (0, 0) is its top-left corner, and (0.5, 1) the middle of its bottom edge. The block’s corner is then moved by whole pixels, so that its glyphs stay on whole pixels.

§layout: TextLayout

How it is laid out: wrapping, alignment and markup.

§color: Color

Its color, sRGB, which tints the glyphs; a markup run’s color takes its place, with its alpha times this one’s.

§glyphs: GlyphMode

Whether the glyphs are a mask in the color, or keep their own.

§layer: u8

Higher layers are drawn in front of lower ones.

§sort: SortMode

How it is ordered within its layer: SortMode::YSort by position.y, as a sprite by its pivot. At one depth, the sprites go first, then the texts in the order they were pushed. A shadow drawn under its text needs the same depth, pushed first: one pixel lower, a y-sorted shadow would be in front.

Implementations§

Source§

impl TextDraw

Source

pub fn new(font: Handle<Font>, position: Vec2) -> Self

A text in font with its block’s top-left corner at position: laid out with TextLayout::new, white, its glyphs a mask, y-sorted in layer 0.

Trait Implementations§

Source§

impl Clone for TextDraw

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TextDraw

Source§

impl Debug for TextDraw

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TextDraw

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TextDraw

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.