44 fn distort<I: Iterator<Item = u32>>(&mut self, random_numbers: &mut I) { |
44 fn distort<I: Iterator<Item = u32>>(&mut self, random_numbers: &mut I) { |
45 unimplemented!() |
45 unimplemented!() |
46 } |
46 } |
47 } |
47 } |
48 |
48 |
49 struct OutlineTemplate { |
49 pub struct OutlineTemplate { |
50 islands: Vec<Vec<Rect>>, |
50 islands: Vec<Vec<Rect>>, |
51 fill_points: Vec<Point>, |
51 fill_points: Vec<Point>, |
52 size: Size, |
52 size: Size, |
53 can_flip: bool, |
53 can_flip: bool, |
54 can_invert: bool, |
54 can_invert: bool, |
55 can_mirror: bool, |
55 can_mirror: bool, |
56 is_negative: bool, |
56 is_negative: bool, |
57 } |
57 } |
58 |
58 |
59 struct TemplatedLandGenerator { |
59 impl OutlineTemplate { |
|
60 pub fn new(size: Size) -> Self { |
|
61 OutlineTemplate { |
|
62 size, |
|
63 islands: Vec::new(), |
|
64 fill_points: Vec::new(), |
|
65 can_flip: false, |
|
66 can_invert: false, |
|
67 can_mirror: false, |
|
68 is_negative: false |
|
69 } |
|
70 } |
|
71 |
|
72 pub fn flippable(self) -> Self { |
|
73 Self { can_flip: true, ..self } |
|
74 } |
|
75 |
|
76 pub fn mirrorable(self) -> Self { |
|
77 Self { can_mirror: true, ..self } |
|
78 } |
|
79 |
|
80 pub fn invertable(self) -> Self { |
|
81 Self { can_invert: true, ..self } |
|
82 } |
|
83 |
|
84 pub fn negative(self) -> Self { |
|
85 Self { is_negative: true, ..self } |
|
86 } |
|
87 |
|
88 pub fn with_fill_points(self, fill_points: Vec<Point>) -> Self |
|
89 { |
|
90 Self { fill_points, ..self } |
|
91 } |
|
92 |
|
93 pub fn with_islands(mut self, islands: Vec<Vec<Rect>>) -> Self { |
|
94 Self { islands, ..self } |
|
95 } |
|
96 |
|
97 pub fn add_fill_points(mut self, points: &[Point]) -> Self { |
|
98 self.fill_points.extend_from_slice(points); self |
|
99 } |
|
100 |
|
101 pub fn add_island(mut self, island: &[Rect]) -> Self { |
|
102 self.islands.push(island.into()); self |
|
103 } |
|
104 } |
|
105 |
|
106 pub struct TemplatedLandGenerator { |
60 outline_template: OutlineTemplate, |
107 outline_template: OutlineTemplate, |
61 } |
108 } |
62 |
109 |
63 impl TemplatedLandGenerator { |
110 impl TemplatedLandGenerator { |
64 pub fn new(outline_template: OutlineTemplate) -> Self { |
111 pub fn new(outline_template: OutlineTemplate) -> Self { |