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