oxidize_pdf/graphics/
path.rs1#[derive(Debug, Clone, Copy, PartialEq)]
2#[repr(u8)]
3pub enum LineCap {
4 Butt = 0,
5 Round = 1,
6 Square = 2,
7}
8
9#[derive(Debug, Clone, Copy, PartialEq)]
10#[repr(u8)]
11pub enum LineJoin {
12 Miter = 0,
13 Round = 1,
14 Bevel = 2,
15}
16
17pub struct PathBuilder {
18 commands: Vec<PathCommand>,
19}
20
21#[derive(Debug, Clone)]
22#[allow(dead_code)]
23pub(crate) enum PathCommand {
24 MoveTo(f64, f64),
25 LineTo(f64, f64),
26 CurveTo(f64, f64, f64, f64, f64, f64),
27 ClosePath,
28}
29
30impl Default for PathBuilder {
31 fn default() -> Self {
32 Self::new()
33 }
34}
35
36#[allow(dead_code)]
37impl PathBuilder {
38 pub fn new() -> Self {
39 Self {
40 commands: Vec::new(),
41 }
42 }
43
44 pub fn move_to(mut self, x: f64, y: f64) -> Self {
45 self.commands.push(PathCommand::MoveTo(x, y));
46 self
47 }
48
49 pub fn line_to(mut self, x: f64, y: f64) -> Self {
50 self.commands.push(PathCommand::LineTo(x, y));
51 self
52 }
53
54 pub fn curve_to(mut self, x1: f64, y1: f64, x2: f64, y2: f64, x3: f64, y3: f64) -> Self {
55 self.commands
56 .push(PathCommand::CurveTo(x1, y1, x2, y2, x3, y3));
57 self
58 }
59
60 pub fn close(mut self) -> Self {
61 self.commands.push(PathCommand::ClosePath);
62 self
63 }
64
65 pub(crate) fn build(self) -> Vec<PathCommand> {
66 self.commands
67 }
68}