pub trait Renderer: 'static + Debug + Send + Sync {
Show 17 methods
fn size(&self) -> Size<f32, Scaled>;
fn theme(&self) -> SystemTheme;
fn clip_to(&self, bounds: Rect<f32, Scaled>) -> Self;
fn clip_bounds(&self) -> Rect<f32, Scaled>;
fn scale(&self) -> DisplayScale<f32>;
fn render_text(
&self,
text: &str,
baseline_origin: impl Displayable<f32, Pixels = Point<f32, Pixels>>,
options: &TextOptions
);
fn measure_text(
&self,
text: &str,
options: &TextOptions
) -> TextMetrics<Scaled>;
fn fill_rect(
&self,
rect: &impl Displayable<f32, Pixels = Rect<f32, Pixels>>,
color: Color
);
fn stroke_rect(
&self,
rect: &impl Displayable<f32, Pixels = Rect<f32, Pixels>>,
options: &StrokeOptions
);
fn stroke_line<P>(&self, point_a: P, point_b: P, options: &StrokeOptions)
where
P: Displayable<f32, Pixels = Point<f32, Pixels>>;
fn draw_image(
&self,
image: &Image,
location: impl Displayable<f32, Pixels = Point<f32, Pixels>>
);
fn bounds(&self) -> Rect<f32, Scaled> { ... }
fn render_text_with_style<F, P>(
&self,
text: &str,
baseline_origin: P,
style: &Style
)
where
F: FallbackComponent<Value = ColorPair>,
P: Displayable<f32, Pixels = Point<f32, Pixels>>,
{ ... }
fn measure_text_with_style(
&self,
text: &str,
style: &Style
) -> TextMetrics<Scaled> { ... }
fn fill_rect_with_style<F, R>(&self, rect: &R, style: &Style)
where
F: FallbackComponent<Value = ColorPair>,
R: Displayable<f32, Pixels = Rect<f32, Pixels>>,
{ ... }
fn stroke_rect_with_style<F, R>(&self, rect: &R, style: &Style)
where
F: FallbackComponent<Value = ColorPair>,
R: Displayable<f32, Pixels = Rect<f32, Pixels>>,
{ ... }
fn stroke_line_with_style<F, P>(
&self,
point_a: P,
point_b: P,
style: &Style
)
where
F: FallbackComponent<Value = ColorPair>,
P: Displayable<f32, Pixels = Point<f32, Pixels>>,
{ ... }
}
Expand description
Implements drawing APIs.
Required Methods
fn theme(&self) -> SystemTheme
fn theme(&self) -> SystemTheme
Returns the current system theme.
Returns a new renderer instance with the state such that each operation
executes as if the origin is bounds.origin
. The returned instance’s
size()
should equal bounds.size
.
fn clip_bounds(&self) -> Rect<f32, Scaled>
fn clip_bounds(&self) -> Rect<f32, Scaled>
A Rect
representing the area being drawn. This rect should be offset
relative to the origin of the renderer.
fn scale(&self) -> DisplayScale<f32>
fn scale(&self) -> DisplayScale<f32>
The scaling factors to use when rendering.
fn render_text(
&self,
text: &str,
baseline_origin: impl Displayable<f32, Pixels = Point<f32, Pixels>>,
options: &TextOptions
)
fn render_text(
&self,
text: &str,
baseline_origin: impl Displayable<f32, Pixels = Point<f32, Pixels>>,
options: &TextOptions
)
Renders text
at baseline_origin
with options
.
fn measure_text(&self, text: &str, options: &TextOptions) -> TextMetrics<Scaled>
fn measure_text(&self, text: &str, options: &TextOptions) -> TextMetrics<Scaled>
Measures text
using options
.
Fills rect
using color
.
fn stroke_rect(
&self,
rect: &impl Displayable<f32, Pixels = Rect<f32, Pixels>>,
options: &StrokeOptions
)
fn stroke_rect(
&self,
rect: &impl Displayable<f32, Pixels = Rect<f32, Pixels>>,
options: &StrokeOptions
)
Strokes the outline of rect
using options
.
fn stroke_line<P>(&self, point_a: P, point_b: P, options: &StrokeOptions) where
P: Displayable<f32, Pixels = Point<f32, Pixels>>,
fn stroke_line<P>(&self, point_a: P, point_b: P, options: &StrokeOptions) where
P: Displayable<f32, Pixels = Point<f32, Pixels>>,
Draws a line between point_a
and point_b
using options
.
fn draw_image(
&self,
image: &Image,
location: impl Displayable<f32, Pixels = Point<f32, Pixels>>
)
fn draw_image(
&self,
image: &Image,
location: impl Displayable<f32, Pixels = Point<f32, Pixels>>
)
Draws an image
at location
.
Provided Methods
A Rect
representing the area being drawn. Due to how rendering
works, the origin is always zero.
fn render_text_with_style<F, P>(
&self,
text: &str,
baseline_origin: P,
style: &Style
) where
F: FallbackComponent<Value = ColorPair>,
P: Displayable<f32, Pixels = Point<f32, Pixels>>,
fn render_text_with_style<F, P>(
&self,
text: &str,
baseline_origin: P,
style: &Style
) where
F: FallbackComponent<Value = ColorPair>,
P: Displayable<f32, Pixels = Point<f32, Pixels>>,
Renders text
at baseline_origin
with options
.
fn measure_text_with_style(
&self,
text: &str,
style: &Style
) -> TextMetrics<Scaled>
fn measure_text_with_style(
&self,
text: &str,
style: &Style
) -> TextMetrics<Scaled>
Measures text
using style
.
fn fill_rect_with_style<F, R>(&self, rect: &R, style: &Style) where
F: FallbackComponent<Value = ColorPair>,
R: Displayable<f32, Pixels = Rect<f32, Pixels>>,
fn fill_rect_with_style<F, R>(&self, rect: &R, style: &Style) where
F: FallbackComponent<Value = ColorPair>,
R: Displayable<f32, Pixels = Rect<f32, Pixels>>,
Fills rect
using style
.
fn stroke_rect_with_style<F, R>(&self, rect: &R, style: &Style) where
F: FallbackComponent<Value = ColorPair>,
R: Displayable<f32, Pixels = Rect<f32, Pixels>>,
fn stroke_rect_with_style<F, R>(&self, rect: &R, style: &Style) where
F: FallbackComponent<Value = ColorPair>,
R: Displayable<f32, Pixels = Rect<f32, Pixels>>,
Strokes the outline of rect
using style
.
fn stroke_line_with_style<F, P>(&self, point_a: P, point_b: P, style: &Style) where
F: FallbackComponent<Value = ColorPair>,
P: Displayable<f32, Pixels = Point<f32, Pixels>>,
fn stroke_line_with_style<F, P>(&self, point_a: P, point_b: P, style: &Style) where
F: FallbackComponent<Value = ColorPair>,
P: Displayable<f32, Pixels = Point<f32, Pixels>>,
Draws a line between point_a
and point_b
using style
.