use std::any::Any;
use galileo_types::cartesian::Size;
use maybe_sync::{MaybeSend, MaybeSync};
use render_bundle::RenderBundle;
use serde::{Deserialize, Serialize};
use crate::Color;
#[cfg(feature = "wgpu")]
mod wgpu;
#[cfg(feature = "wgpu")]
pub use wgpu::WgpuRenderer;
pub mod point_paint;
pub mod render_bundle;
pub mod text;
pub trait Canvas {
fn size(&self) -> Size;
fn pack_bundle(&self, bundle: &RenderBundle) -> Box<dyn PackedBundle>;
fn draw_bundles(&mut self, bundles: &[&dyn PackedBundle], options: RenderOptions);
fn draw_bundles_with_opacity(
&mut self,
bundles: &[(&dyn PackedBundle, f32)],
options: RenderOptions,
);
fn draw_screen_sets(&mut self) -> bool;
}
pub trait PackedBundle: MaybeSend + MaybeSync {
fn as_any(&self) -> &dyn Any;
}
#[derive(Debug, Copy, Clone)]
pub struct RenderOptions {
pub antialias: bool,
}
impl Default for RenderOptions {
fn default() -> Self {
Self { antialias: true }
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct PolygonPaint {
pub color: Color,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct LinePaint {
pub color: Color,
pub width: f64,
pub offset: f64,
pub line_cap: LineCap,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum LineCap {
Round,
Butt,
}
impl From<LineCap> for lyon::path::LineCap {
fn from(val: LineCap) -> Self {
match val {
LineCap::Round => lyon::lyon_tessellation::LineCap::Round,
LineCap::Butt => lyon::lyon_tessellation::LineCap::Butt,
}
}
}
pub struct ImagePaint {
pub opacity: u8,
}