#![doc = include_str!("../README.md")]
pub mod mermaid;
pub mod svg;
pub mod worker;
pub const MAX_PIXELS: usize = 1_000_000;
pub const MAX_EDGE: u32 = 8192;
#[derive(Debug)]
pub struct Raster {
pub width: u32,
pub height: u32,
pub original_width: u32,
pub original_height: u32,
pub rgba: Vec<u8>,
}
#[derive(Clone, Copy, Debug)]
pub struct RasterOptions {
pub bounds: (u32, u32),
pub scale: f64,
}
impl RasterOptions {
pub const fn fit(bounds: (u32, u32)) -> Self {
Self { bounds, scale: 1. }
}
pub const fn scaled(scale: f64) -> Self {
Self {
bounds: (MAX_EDGE, MAX_EDGE),
scale,
}
}
pub(crate) fn valid(self) -> bool {
self.bounds.0 > 0
&& self.bounds.1 > 0
&& self.bounds.0 <= MAX_EDGE
&& self.bounds.1 <= MAX_EDGE
&& self.scale.is_finite()
&& self.scale > 0.
&& self.scale <= 4.
}
}