hayro_interpret/
types.rs

1use crate::color::Color;
2use crate::pattern::Pattern;
3use kurbo::{Affine, BezPath, Cap, Join};
4use smallvec::SmallVec;
5
6/// A clip path.
7#[derive(Debug, Clone)]
8pub struct ClipPath {
9    /// The clipping path.
10    pub path: BezPath,
11    /// The fill rule.
12    pub fill: FillRule,
13}
14
15/// A structure holding 3-channel RGB data.
16#[derive(Clone)]
17pub struct RgbData {
18    /// The actual data. It is guaranteed to have the length width * height * 3.
19    pub data: Vec<u8>,
20    /// The width.
21    pub width: u32,
22    /// The height.
23    pub height: u32,
24    /// Whether the image should be interpolated.
25    pub interpolate: bool,
26}
27
28/// A structure holding 1-channel luma data.
29#[derive(Clone)]
30pub struct LumaData {
31    /// The actual data. It is guaranteed to have the length width * height.
32    pub data: Vec<u8>,
33    /// The width.
34    pub width: u32,
35    /// The height.
36    pub height: u32,
37    /// Whether the image should be interpolated.
38    pub interpolate: bool,
39}
40
41/// A type of paint.
42#[derive(Clone, Debug)]
43pub enum PaintType<'a> {
44    /// A solid RGBA color.
45    Color(Color),
46    /// A PDF pattern.
47    Pattern(Box<Pattern<'a>>),
48}
49
50/// A paint.
51#[derive(Clone, Debug)]
52pub struct Paint<'a> {
53    /// A transform to apply to the paint.
54    pub paint_transform: Affine,
55    /// The underlying type of paint.
56    pub paint_type: PaintType<'a>,
57}
58
59/// Stroke properties.
60#[derive(Clone, Debug)]
61pub struct StrokeProps {
62    /// The line width.
63    pub line_width: f32,
64    /// The line cap.
65    pub line_cap: Cap,
66    /// The line join.
67    pub line_join: Join,
68    /// The miter limit.
69    pub miter_limit: f32,
70    /// The dash array.
71    pub dash_array: SmallVec<[f32; 4]>,
72    /// The dash offset.
73    pub dash_offset: f32,
74}
75
76/// A fill rule.
77#[derive(Clone, Debug, Copy)]
78pub enum FillRule {
79    /// Non-zero filling.
80    NonZero,
81    /// Even-odd filling.
82    EvenOdd,
83}
84
85/// Fill properties.
86#[derive(Clone, Debug)]
87pub struct FillProps {
88    /// The fill rule.
89    pub fill_rule: FillRule,
90}