use super::preludes::*;
use crate::hash::StaticHash128;
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "rkyv", derive(Archive, rDeser, rSer))]
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
pub struct ImageItem {
pub image: Arc<Image>,
pub size: Size,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "rkyv", derive(Archive, rDeser, rSer))]
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
pub struct Image {
pub data: Arc<[u8]>,
pub format: ImmutStr,
pub size: Axes<u32>,
pub hash: Fingerprint,
pub attrs: Vec<ImageAttr>,
}
impl Image {
pub fn width(&self) -> u32 {
self.size.x
}
pub fn height(&self) -> u32 {
self.size.y
}
}
impl Hash for Image {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.hash.hash(state);
}
}
impl StaticHash128 for Image {
fn get_hash(&self) -> u128 {
self.hash.to_u128()
}
}
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "rkyv", derive(Archive, rDeser, rSer))]
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
pub enum ImageAttr {
Alt(ImmutStr),
ImageRendering(ImmutStr),
}
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "rkyv", derive(Archive, rDeser, rSer))]
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
pub struct PathItem {
pub d: ImmutStr,
pub size: Option<Size>,
pub styles: Vec<PathStyle>,
}
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "rkyv", derive(Archive, rDeser, rSer))]
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
pub enum PathStyle {
Fill(ImmutStr),
Stroke(ImmutStr),
StrokeLineCap(ImmutStr),
StrokeLineJoin(ImmutStr),
StrokeMitterLimit(Scalar),
StrokeDashOffset(Abs),
StrokeDashArray(Arc<[Abs]>),
StrokeWidth(Abs),
FillRule(ImmutStr),
}
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "rkyv", derive(Archive, rDeser, rSer))]
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
pub struct PatternItem {
pub frame: Fingerprint,
pub size: Size,
pub spacing: Size,
}