iced_graphics/
geometry.rs

1//! Build and draw geometry.
2pub mod fill;
3pub mod frame;
4pub mod path;
5pub mod stroke;
6
7mod cache;
8mod style;
9mod text;
10
11pub use cache::Cache;
12pub use fill::Fill;
13pub use frame::Frame;
14pub use path::Path;
15pub use stroke::{LineCap, LineDash, LineJoin, Stroke};
16pub use style::Style;
17pub use text::Text;
18
19pub use crate::core::{Image, Svg};
20pub use crate::gradient::{self, Gradient};
21
22use crate::cache::Cached;
23use crate::core::{self, Size};
24
25/// A renderer capable of drawing some [`Self::Geometry`].
26pub trait Renderer: core::Renderer {
27    /// The kind of geometry this renderer can draw.
28    type Geometry: Cached;
29
30    /// The kind of [`Frame`] this renderer supports.
31    type Frame: frame::Backend<Geometry = Self::Geometry>;
32
33    /// Creates a new [`Self::Frame`].
34    fn new_frame(&self, size: Size) -> Self::Frame;
35
36    /// Draws the given [`Self::Geometry`].
37    fn draw_geometry(&mut self, geometry: Self::Geometry);
38}
39
40#[cfg(debug_assertions)]
41impl Renderer for () {
42    type Geometry = ();
43    type Frame = ();
44
45    fn new_frame(&self, _size: Size) -> Self::Frame {}
46
47    fn draw_geometry(&mut self, _geometry: Self::Geometry) {}
48}