rust/landgen/src/wavefront_collapse/tile_image.rs
branchtransitional_engine
changeset 15949 659c92124c26
parent 15948 9bd828451d77
child 15950 168f44ef9b67
equal deleted inserted replaced
15948:9bd828451d77 15949:659c92124c26
    21 
    21 
    22     pub fn reversed(&self) -> Self {
    22     pub fn reversed(&self) -> Self {
    23         Self {
    23         Self {
    24             id: self.id.clone(),
    24             id: self.id.clone(),
    25             symmetrical: self.symmetrical,
    25             symmetrical: self.symmetrical,
    26             reverse: !self.symmetrical && !self.reverse,
    26             reverse: !self.reverse,
    27         }
    27         }
    28     }
    28     }
    29 
    29 
    30     pub fn is_compatible(&self, other: &Self) -> bool {
    30     pub fn is_compatible(&self, other: &Self) -> bool {
    31         self.id == other.id && (self.reverse != other.reverse || self.symmetrical)
    31         self.id == other.id && ((self.reverse != other.reverse) || self.symmetrical)
    32     }
    32     }
    33 }
    33 }
    34 
    34 
    35 #[derive(Clone)]
    35 #[derive(Clone)]
    36 pub struct TileImage<T, I: PartialEq + Clone> {
    36 pub struct TileImage<T, I: PartialEq + Clone> {
    37     image: Rc<Vec2D<T>>,
    37     image: Rc<Vec2D<T>>,
    38     transform: Transform,
    38     pub transform: Transform,
    39     top: Edge<I>,
    39     top: Edge<I>,
    40     right: Edge<I>,
    40     right: Edge<I>,
    41     bottom: Edge<I>,
    41     bottom: Edge<I>,
    42     left: Edge<I>,
    42     left: Edge<I>,
    43 }
    43 }
   106 
   106 
   107     pub fn rotated270(&self) -> Self {
   107     pub fn rotated270(&self) -> Self {
   108         Self {
   108         Self {
   109             image: self.image.clone(),
   109             image: self.image.clone(),
   110             transform: self.transform.rotate270(),
   110             transform: self.transform.rotate270(),
   111             top: self.left.clone(),
   111             top: self.right.clone(),
   112             right: self.top.clone(),
   112             right: self.bottom.clone(),
   113             bottom: self.right.clone(),
   113             bottom: self.left.clone(),
   114             left: self.bottom.clone(),
   114             left: self.top.clone(),
   115         }
   115         }
   116     }
   116     }
   117 
   117 
   118     pub fn right_edge(&self) -> &Edge<I> {
   118     pub fn right_edge(&self) -> &Edge<I> {
   119         &self.right
   119         &self.right
   154                 };
   154                 };
   155 
   155 
   156                 self.image.get(image_row, image_column)
   156                 self.image.get(image_row, image_column)
   157             },
   157             },
   158             Transform::Rotate90(_) => {
   158             Transform::Rotate90(_) => {
   159                 let image_row = if self.transform.is_flipped() {
   159                 let image_row = if self.transform.is_mirrored() {
   160                     column
   160                     column
   161                 } else {
   161                 } else {
   162                     self.image.height().wrapping_sub(1).wrapping_sub(column)
   162                     self.image.height().wrapping_sub(1).wrapping_sub(column)
   163                 };
   163                 };
   164 
   164 
   165                 let image_column = if self.transform.is_mirrored() {
   165                 let image_column = if self.transform.is_flipped() {
   166                     self.image.width().wrapping_sub(1).wrapping_sub(row)
   166                     self.image.width().wrapping_sub(1).wrapping_sub(row)
   167                 } else {
   167                 } else {
   168                     row
   168                     row
   169                 };
   169                 };
   170 
   170