pub struct TextRenderer { /* private fields */ }Expand description
文字渲染器
使用内置位图字体图集渲染 ASCII 文本到屏幕空间。
Implementations§
Source§impl TextRenderer
impl TextRenderer
Sourcepub fn new(device: &RenderDevice, format: TextureFormat) -> Self
pub fn new(device: &RenderDevice, format: TextureFormat) -> Self
Sourcepub fn draw_text(
&mut self,
device: &RenderDevice,
encoder: &mut CommandEncoder,
target: &TextureView,
text: &str,
x: f32,
y: f32,
font_size: f32,
color: Vec3,
screen_w: f32,
screen_h: f32,
)
pub fn draw_text( &mut self, device: &RenderDevice, encoder: &mut CommandEncoder, target: &TextureView, text: &str, x: f32, y: f32, font_size: f32, color: Vec3, screen_w: f32, screen_h: f32, )
渲染文本到屏幕
§参数
device: GPU 渲染设备encoder: 命令编码器target: 渲染目标纹理视图text: 要渲染的 ASCII 文本x,y: 屏幕坐标(左上角起点,像素)font_size: 字体大小(像素高度)color: 文字颜色 (RGB)screen_w,screen_h: 屏幕尺寸(像素)
Auto Trait Implementations§
impl !Freeze for TextRenderer
impl !RefUnwindSafe for TextRenderer
impl Send for TextRenderer
impl Sync for TextRenderer
impl Unpin for TextRenderer
impl UnsafeUnpin for TextRenderer
impl !UnwindSafe for TextRenderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.