rust/landgen/src/wavefront_collapse/generator.rs
branchtransitional_engine
changeset 15916 e82de0410da5
parent 15915 8f093b1b18bc
child 15917 60b5639cc3a5
--- a/rust/landgen/src/wavefront_collapse/generator.rs	Thu Feb 02 08:41:31 2023 +0100
+++ b/rust/landgen/src/wavefront_collapse/generator.rs	Fri Feb 03 14:44:33 2023 +0100
@@ -1,4 +1,4 @@
-use super::tile_image::TileImage;
+use super::tile_image::{Edge, TileImage};
 use super::wavefront_collapse::WavefrontCollapse;
 use crate::{LandGenerationParameters, LandGenerator};
 use integral_geometry::Size;
@@ -17,7 +17,12 @@
         }
     }
 
-    pub fn load_template<T: Copy + PartialEq + Default>(&self, parameters: &LandGenerationParameters<T>) -> Vec<TileImage<T>> {
+    pub fn load_template<T: Copy + PartialEq + Default>(
+        &self,
+        parameters: &LandGenerationParameters<T>,
+    ) -> Vec<TileImage<T, String>> {
+        let mut result = Vec::new();
+
         let file = File::open("sample.png").expect("file exists");
         let decoder = Decoder::new(BufReader::new(file));
         let mut reader = decoder.read_info().unwrap();
@@ -47,7 +52,18 @@
             }
         }
 
-        TileImage::<T>::new(tiles_image).split(3, 3)
+        let top_edge = Edge::new("edge".to_owned(), false);
+        let right_edge = Edge::new("edge".to_owned(), false);
+        let bottom_edge = Edge::new("edge".to_owned(), false);
+        let left_edge = Edge::new("edge".to_owned(), false);
+
+        let tile =
+            TileImage::<T, String>::new(tiles_image, top_edge, right_edge, bottom_edge, left_edge);
+
+        result.push(tile.clone());
+        result.push(tile.mirrored());
+
+        result
     }
 }
 
@@ -66,13 +82,13 @@
 #[cfg(test)]
 mod tests {
     use super::WavefrontCollapseLandGenerator;
-    use crate::{LandGenerator, LandGenerationParameters};
+    use crate::{LandGenerationParameters, LandGenerator};
     use integral_geometry::Size;
     use vec2d::Vec2D;
 
     #[test]
     fn test_generation() {
-        let wfc_gen =WavefrontCollapseLandGenerator::new();
+        let wfc_gen = WavefrontCollapseLandGenerator::new();
         let landgen_params = LandGenerationParameters::new(0u8, 255u8, 0, true, true);
         wfc_gen.generate_land(&landgen_params, &mut std::iter::repeat(1u32));
     }