Skip to main content

Renderer

Trait Renderer 

Source
pub trait Renderer {
    // Required methods
    fn fill_rect(&mut self, rect: Rect, radius: Corners<f32>, color: Color);
    fn border(
        &mut self,
        rect: Rect,
        widths: Sides<f32>,
        colors: Sides<Color>,
        radius: Corners<f32>,
    );
    fn text(
        &mut self,
        text: &str,
        font: &FontSpec,
        top_left: Point,
        color: Color,
    );
    fn push_clip(&mut self, rect: Rect);
    fn pop_clip(&mut self);
    fn push_opacity(&mut self, opacity: f32);
    fn pop_opacity(&mut self);
}
Expand description

Draws. Implemented by a backend for one frame’s drawing target.

Coordinates are window pixels with the origin at the top left. Colours are straight-alpha sRGB. Rectangles are filled and stroked without anti-aliasing where the backend can manage it, so that 1px borders stay crisp.

Required Methods§

Source

fn fill_rect(&mut self, rect: Rect, radius: Corners<f32>, color: Color)

Source

fn border( &mut self, rect: Rect, widths: Sides<f32>, colors: Sides<Color>, radius: Corners<f32>, )

A border drawn inside rect, one width and colour per side.

Source

fn text(&mut self, text: &str, font: &FontSpec, top_left: Point, color: Color)

A single line of text, its line box starting at top_left. The backend places the baseline inside the line box the same way Fonts::measure measured it.

Source

fn push_clip(&mut self, rect: Rect)

Restricts drawing to rect until the matching pop_clip.

Source

fn pop_clip(&mut self)

Source

fn push_opacity(&mut self, opacity: f32)

Draws everything until the matching pop_opacity through a layer with the given opacity.

Source

fn pop_opacity(&mut self)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§