1use crate::CacheKey;
2use crate::color::Color;
3use crate::pattern::Pattern;
4use crate::util::hash128;
5use kurbo::{BezPath, Cap, Join};
6use smallvec::{SmallVec, smallvec};
7
8#[derive(Debug, Clone)]
10pub struct ClipPath {
11 pub path: BezPath,
13 pub fill: FillRule,
15}
16
17impl CacheKey for ClipPath {
18 fn cache_key(&self) -> u128 {
19 hash128(&(&self.path.to_svg(), &self.fill))
20 }
21}
22
23#[derive(Clone)]
25pub struct RgbData {
26 pub data: Vec<u8>,
28 pub width: u32,
30 pub height: u32,
32 pub interpolate: bool,
34}
35
36#[derive(Clone)]
38pub struct LumaData {
39 pub data: Vec<u8>,
41 pub width: u32,
43 pub height: u32,
45 pub interpolate: bool,
47}
48
49#[derive(Clone, Debug)]
51pub enum Paint<'a> {
52 Color(Color),
54 Pattern(Box<Pattern<'a>>),
56}
57
58#[derive(Clone, Debug)]
60pub struct StrokeProps {
61 pub line_width: f32,
63 pub line_cap: Cap,
65 pub line_join: Join,
67 pub miter_limit: f32,
69 pub dash_array: SmallVec<[f32; 4]>,
71 pub dash_offset: f32,
73}
74
75impl Default for StrokeProps {
76 fn default() -> Self {
77 Self {
78 line_width: 1.0,
79 line_cap: Cap::Butt,
80 line_join: Join::Miter,
81 miter_limit: 10.0,
82 dash_array: smallvec![],
83 dash_offset: 0.0,
84 }
85 }
86}
87
88#[derive(Clone, Debug, Copy, Hash, PartialEq, Eq)]
90pub enum FillRule {
91 NonZero,
93 EvenOdd,
95}