Struct gfx_text::Renderer

source ·
pub struct Renderer<R: Resources, F: Factory<R>> { /* private fields */ }
Expand description

Text renderer.

Implementations§

source§

impl<R: Resources, F: Factory<R>> Renderer<R, F>

source

pub fn add(&mut self, text: &str, pos: [i32; 2], color: [f32; 4])

Add some text to the current draw scene relative to the top left corner of the screen using pixel coordinates.

source

pub fn add_anchored( &mut self, text: &str, pos: [i32; 2], horizontal: HorizontalAnchor, vertical: VerticalAnchor, color: [f32; 4] )

Add text to the draw scene by anchoring an edge or mid-point to a position defined in screen pixel coordinates.

source

pub fn add_at(&mut self, text: &str, pos: [f32; 3], color: [f32; 4])

Add some text to the draw scene using absolute world coordinates.

source

pub fn draw<C: CommandBuffer<R>, T: RenderFormat>( &mut self, encoder: &mut Encoder<R, C>, target: &RenderTargetView<R, T> ) -> Result<(), Error>

Draw the current scene and clear state.

Examples
text.add("Test1", [10, 10], [1.0, 0.0, 0.0, 1.0]);
text.add("Test2", [20, 20], [0.0, 1.0, 0.0, 1.0]);
text.draw(&mut encoder, &color_output).unwrap();
source

pub fn draw_at<C: CommandBuffer<R>, T: RenderFormat>( &mut self, encoder: &mut Encoder<R, C>, target: &RenderTargetView<R, T>, proj: [[f32; 4]; 4] ) -> Result<(), Error>

Draw using provided projection matrix.

Examples
text.add_at("Test1", [6.0, 0.0, 0.0], [1.0, 0.0, 0.0, 1.0]);
text.add_at("Test2", [0.0, 5.0, 0.0], [0.0, 1.0, 0.0, 1.0]);
text.draw_at(&mut encoder, &color_output, camera_projection).unwrap();
source

pub fn measure(&self, text: &str) -> (i32, i32)

Get the bounding box size of a string as rendered by this font.

Auto Trait Implementations§

§

impl<R, F> !RefUnwindSafe for Renderer<R, F>

§

impl<R, F> Send for Renderer<R, F>where F: Send,

§

impl<R, F> Sync for Renderer<R, F>where F: Sync,

§

impl<R, F> Unpin for Renderer<R, F>where F: Unpin,

§

impl<R, F> !UnwindSafe for Renderer<R, F>

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.