Trait paws::Renderer [−][src]
pub trait Renderer {
type Font;
fn push(&mut self);
fn pop(&mut self);
fn translate(&mut self, vec: Vector);
fn clip(&mut self, rect: Rect);
fn fill(&mut self, rect: Rect, color: Color, radius: f32);
fn outline(&mut self, rect: Rect, color: Color, radius: f32, thickness: f32);
fn line(
&mut self,
a: Point,
b: Point,
color: Color,
cap: LineCap,
thickness: f32
);
fn text(
&mut self,
rect: Rect,
font: &Self::Font,
text: &str,
color: Color,
alignment: Alignment
) -> f32;
}
Expand description
The renderer trait, used for all things drawing-related.
A note on rendering lines
Renderers should try their best to make lines pixel-perfect. What this means is that lines with a thickness of 1.0 shouldn’t get placed inbetween pixels, as that will make it look blurred out. Some vector graphics renderers do that, and on those renderers stroke points should get moved by half a pixel.
Examples of such renderers include HTML5 canvas, Cairo, Skia.
Associated Types
Required methods
Pops the topmost transform matrix and clip region off the stack and overwrites the current transform matrix with it.
Updates the clip region to the intersection of the current clip region and the provided rectangle.
Initially, the clip region spans the whole window. This only allows for shrinking the clip region in size.
The only way to increase its size is to use push()
and pop()
.
The rectangle should be subject to translation.
Draws a fill for the provided rectangle, with the given color and corner radius.
Draws an outline for the provided rectangle, with the given color, corner radius, and thickness.
Draws a line from point A to point B, with the given color, cap type, and thickness.