14090
|
1 |
use integral_geometry::{Point, Rect, Size};
|
|
2 |
|
14147
|
3 |
#[derive(Debug)]
|
14090
|
4 |
pub struct OutlineTemplate {
|
|
5 |
pub islands: Vec<Vec<Rect>>,
|
|
6 |
pub fill_points: Vec<Point>,
|
|
7 |
pub size: Size,
|
|
8 |
pub can_flip: bool,
|
|
9 |
pub can_invert: bool,
|
|
10 |
pub can_mirror: bool,
|
|
11 |
pub is_negative: bool,
|
|
12 |
}
|
|
13 |
|
|
14 |
impl OutlineTemplate {
|
|
15 |
pub fn new(size: Size) -> Self {
|
|
16 |
OutlineTemplate {
|
|
17 |
size,
|
|
18 |
islands: Vec::new(),
|
|
19 |
fill_points: Vec::new(),
|
|
20 |
can_flip: false,
|
|
21 |
can_invert: false,
|
|
22 |
can_mirror: false,
|
|
23 |
is_negative: false,
|
|
24 |
}
|
|
25 |
}
|
|
26 |
|
|
27 |
pub fn flippable(self) -> Self {
|
|
28 |
Self {
|
|
29 |
can_flip: true,
|
|
30 |
..self
|
|
31 |
}
|
|
32 |
}
|
|
33 |
|
|
34 |
pub fn mirrorable(self) -> Self {
|
|
35 |
Self {
|
|
36 |
can_mirror: true,
|
|
37 |
..self
|
|
38 |
}
|
|
39 |
}
|
|
40 |
|
|
41 |
pub fn invertable(self) -> Self {
|
|
42 |
Self {
|
|
43 |
can_invert: true,
|
|
44 |
..self
|
|
45 |
}
|
|
46 |
}
|
|
47 |
|
|
48 |
pub fn negative(self) -> Self {
|
|
49 |
Self {
|
|
50 |
is_negative: true,
|
|
51 |
..self
|
|
52 |
}
|
|
53 |
}
|
|
54 |
|
|
55 |
pub fn with_fill_points(self, fill_points: Vec<Point>) -> Self {
|
|
56 |
Self {
|
|
57 |
fill_points,
|
|
58 |
..self
|
|
59 |
}
|
|
60 |
}
|
|
61 |
|
|
62 |
pub fn with_islands(self, islands: Vec<Vec<Rect>>) -> Self {
|
|
63 |
Self { islands, ..self }
|
|
64 |
}
|
|
65 |
|
|
66 |
pub fn add_fill_points(mut self, points: &[Point]) -> Self {
|
|
67 |
self.fill_points.extend_from_slice(points);
|
|
68 |
self
|
|
69 |
}
|
|
70 |
|
|
71 |
pub fn add_island(mut self, island: &[Rect]) -> Self {
|
|
72 |
self.islands.push(island.into());
|
|
73 |
self
|
|
74 |
}
|
|
75 |
}
|