Skip to main content

TextShape

Struct TextShape 

Source
pub struct TextShape {
    pub at: Pos,
    pub area: Size,
    pub text: Text,
}
Expand description

The block, its area’s top-left at at, each line centred in area.

The placement is the area’s, and the arithmetic is a signed subtraction truncated toward zero. A zero area is an area of zero rather than a sentinel saying “start at at”: 0x0 puts the offsets at -width/2 and -height/2, so the block sits around at and a box with no interior still draws its text. Nothing is clipped to the area, so a block wider than the area it was given overflows on both sides.

A complete shape in the sense of Complete and fragment: constructed, drawn and discarded. It writes one literal cell per glyph, an empty line writes nothing, and a line shorter than the area writes only its glyphs rather than spaces to fill it.

Fields§

§at: Pos

The block’s area’s top-left, which is the point the offsets are measured from.

§area: Size

The area each line is centred in.

§text: Text

The block itself.

Trait Implementations§

Source§

impl Debug for TextShape

Source§

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

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

impl Shape for TextShape

Source§

fn draw(&self, surface: &mut dyn Surface)

Draws this shape’s cells into surface.

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> 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 = !

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.