Skip to main content

RenderBackend

Trait RenderBackend 

Source
pub trait RenderBackend {
    // Required methods
    fn initialize(&mut self) -> Result<(), Box<dyn Error>>;
    fn cleanup(&mut self);
    fn begin_frame(&mut self);
    fn end_frame(&mut self);
    fn render_component(
        &mut self,
        component: &Component,
        x: f32,
        y: f32,
        width: f32,
        height: f32,
    );
    fn draw_rect(
        &mut self,
        x: f32,
        y: f32,
        width: f32,
        height: f32,
        style: &Style,
    );
    fn draw_text(&mut self, text: &str, x: f32, y: f32, style: &Style);
    fn measure_text(&mut self, text: &str, style: &Style) -> (f32, f32);
}
Expand description

渲染系统相关功能 渲染后端 trait

Required Methods§

Source

fn initialize(&mut self) -> Result<(), Box<dyn Error>>

初始化渲染后端

Source

fn cleanup(&mut self)

清理渲染后端

Source

fn begin_frame(&mut self)

开始渲染帧

Source

fn end_frame(&mut self)

结束渲染帧

Source

fn render_component( &mut self, component: &Component, x: f32, y: f32, width: f32, height: f32, )

渲染组件

Source

fn draw_rect(&mut self, x: f32, y: f32, width: f32, height: f32, style: &Style)

绘制矩形

Source

fn draw_text(&mut self, text: &str, x: f32, y: f32, style: &Style)

绘制文本

Source

fn measure_text(&mut self, text: &str, style: &Style) -> (f32, f32)

测量文本尺寸

Implementors§