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)]
22enum PathCommand {
23 MoveTo(f64, f64),
24 LineTo(f64, f64),
25 CurveTo(f64, f64, f64, f64, f64, f64),
26 ClosePath,
27}
28
29impl PathBuilder {
30 pub fn new() -> Self {
31 Self {
32 commands: Vec::new(),
33 }
34 }
35
36 pub fn move_to(mut self, x: f64, y: f64) -> Self {
37 self.commands.push(PathCommand::MoveTo(x, y));
38 self
39 }
40
41 pub fn line_to(mut self, x: f64, y: f64) -> Self {
42 self.commands.push(PathCommand::LineTo(x, y));
43 self
44 }
45
46 pub fn curve_to(mut self, x1: f64, y1: f64, x2: f64, y2: f64, x3: f64, y3: f64) -> Self {
47 self.commands.push(PathCommand::CurveTo(x1, y1, x2, y2, x3, y3));
48 self
49 }
50
51 pub fn close(mut self) -> Self {
52 self.commands.push(PathCommand::ClosePath);
53 self
54 }
55
56 pub fn build(self) -> Vec<PathCommand> {
57 self.commands
58 }
59}