2023-05-11 15:37:56 +02:00
|
|
|
//! Build and draw geometry.
|
2023-03-03 04:57:55 +01:00
|
|
|
pub mod fill;
|
2024-03-22 01:35:14 +01:00
|
|
|
pub mod frame;
|
2023-03-03 04:57:55 +01:00
|
|
|
pub mod path;
|
|
|
|
|
pub mod stroke;
|
|
|
|
|
|
2024-03-22 01:35:14 +01:00
|
|
|
mod cache;
|
2023-03-03 04:57:55 +01:00
|
|
|
mod style;
|
|
|
|
|
mod text;
|
|
|
|
|
|
2024-03-22 01:35:14 +01:00
|
|
|
pub use cache::Cache;
|
2023-03-03 04:57:55 +01:00
|
|
|
pub use fill::Fill;
|
2024-03-22 01:35:14 +01:00
|
|
|
pub use frame::Frame;
|
2023-03-03 04:57:55 +01:00
|
|
|
pub use path::Path;
|
|
|
|
|
pub use stroke::{LineCap, LineDash, LineJoin, Stroke};
|
|
|
|
|
pub use style::Style;
|
|
|
|
|
pub use text::Text;
|
|
|
|
|
|
2024-08-04 04:52:55 +02:00
|
|
|
pub use crate::core::{Image, Svg};
|
2023-05-19 03:32:21 +02:00
|
|
|
pub use crate::gradient::{self, Gradient};
|
2023-03-03 04:57:55 +01:00
|
|
|
|
2024-04-30 07:57:54 +02:00
|
|
|
use crate::cache::Cached;
|
2024-03-22 05:27:31 +01:00
|
|
|
use crate::core::{self, Size};
|
2024-03-21 22:27:17 +01:00
|
|
|
|
2023-09-09 12:24:47 +02:00
|
|
|
/// A renderer capable of drawing some [`Self::Geometry`].
|
2024-03-22 05:27:31 +01:00
|
|
|
pub trait Renderer: core::Renderer {
|
2023-06-29 07:55:52 +02:00
|
|
|
/// The kind of geometry this renderer can draw.
|
2024-03-22 01:53:48 +01:00
|
|
|
type Geometry: Cached;
|
2024-03-21 22:27:17 +01:00
|
|
|
|
|
|
|
|
/// The kind of [`Frame`] this renderer supports.
|
2024-03-22 01:35:14 +01:00
|
|
|
type Frame: frame::Backend<Geometry = Self::Geometry>;
|
2024-03-21 22:27:17 +01:00
|
|
|
|
2024-03-22 01:53:48 +01:00
|
|
|
/// Creates a new [`Self::Frame`].
|
2024-03-21 22:27:17 +01:00
|
|
|
fn new_frame(&self, size: Size) -> Self::Frame;
|
|
|
|
|
|
|
|
|
|
/// Draws the given [`Self::Geometry`].
|
|
|
|
|
fn draw_geometry(&mut self, geometry: Self::Geometry);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-22 05:41:15 +01:00
|
|
|
#[cfg(debug_assertions)]
|
|
|
|
|
impl Renderer for () {
|
|
|
|
|
type Geometry = ();
|
|
|
|
|
type Frame = ();
|
|
|
|
|
|
|
|
|
|
fn new_frame(&self, _size: Size) -> Self::Frame {}
|
|
|
|
|
|
|
|
|
|
fn draw_geometry(&mut self, _geometry: Self::Geometry) {}
|
|
|
|
|
}
|