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§
fn fill_rect(&mut self, rect: Rect, radius: Corners<f32>, color: Color)
Sourcefn border(
&mut self,
rect: Rect,
widths: Sides<f32>,
colors: Sides<Color>,
radius: Corners<f32>,
)
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.
Sourcefn text(&mut self, text: &str, font: &FontSpec, top_left: Point, color: Color)
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.
fn pop_clip(&mut self)
Sourcefn push_opacity(&mut self, opacity: f32)
fn push_opacity(&mut self, opacity: f32)
Draws everything until the matching pop_opacity
through a layer with the given opacity.
fn pop_opacity(&mut self)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".