rust/landgen/src/wavefront_collapse/transform.rs
author unC0Rr
Sun, 12 Feb 2023 15:10:10 +0100
branchtransitional_engine
changeset 15919 659c92124c26
parent 15918 9bd828451d77
child 15920 168f44ef9b67
permissions -rw-r--r--
Fix some bugs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
     1
#[derive(Debug, PartialEq, Clone, Copy)]
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
     2
pub enum SymmetryTransform {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
     3
    Id,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
     4
    Flip,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
     5
    Mirror,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
     6
    FlipMirror,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
     7
}
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
     8
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
     9
#[derive(Debug, PartialEq, Clone, Copy)]
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    10
pub enum Transform {
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    11
    Rotate0(SymmetryTransform),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    12
    Rotate90(SymmetryTransform),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    13
}
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    14
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    15
impl Default for Transform {
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    16
    fn default() -> Self {
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    17
        Transform::Rotate0(SymmetryTransform::Id)
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    18
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    19
}
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    20
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    21
impl SymmetryTransform {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    22
    pub fn mirror(&self) -> Self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    23
        use SymmetryTransform::*;
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    24
        match self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    25
            Id => Mirror,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    26
            Flip => FlipMirror,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    27
            Mirror => Id,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    28
            FlipMirror => Flip,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    29
        }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    30
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    31
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    32
    pub fn flip(&self) -> Self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    33
        use SymmetryTransform::*;
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    34
        match self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    35
            Id => Flip,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    36
            Flip => Id,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    37
            Mirror => FlipMirror,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    38
            FlipMirror => Mirror,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    39
        }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    40
    }
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    41
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    42
    pub fn is_mirrored(&self) -> bool {
15919
659c92124c26 Fix some bugs
unC0Rr
parents: 15918
diff changeset
    43
        use SymmetryTransform::*;
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    44
        match self {
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    45
            Id => false,
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    46
            Flip => false,
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    47
            Mirror => true,
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    48
            FlipMirror => true,
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    49
        }
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    50
    }
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    51
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    52
    pub fn is_flipped(&self) -> bool {
15919
659c92124c26 Fix some bugs
unC0Rr
parents: 15918
diff changeset
    53
        use SymmetryTransform::*;
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    54
        match self {
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    55
            Id => false,
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    56
            Flip => true,
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    57
            Mirror => false,
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    58
            FlipMirror => true,
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    59
        }
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    60
    }
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    61
}
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    62
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    63
impl Transform {
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    64
    pub fn new() -> Self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    65
        Self::default()
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    66
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    67
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    68
    pub fn mirror(self) -> Transform {
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    69
        match self {
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    70
            Transform::Rotate0(s) => Transform::Rotate0(s.mirror()),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    71
            Transform::Rotate90(s) => Transform::Rotate90(s.flip()),
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    72
        }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    73
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    74
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    75
    pub fn flip(self) -> Transform {
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    76
        match self {
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    77
            Transform::Rotate0(s) => Transform::Rotate0(s.flip()),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    78
            Transform::Rotate90(s) => Transform::Rotate90(s.mirror()),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    79
        }
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    80
    }
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    81
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    82
    pub fn rotate90(self) -> Transform {
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    83
        match self {
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    84
            Transform::Rotate0(s) => Transform::Rotate90(s),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    85
            Transform::Rotate90(s) => Transform::Rotate0(s.flip().mirror()),
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    86
        }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    87
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    88
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    89
    pub fn rotate180(self) -> Transform {
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    90
        match self {
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    91
            Transform::Rotate0(s) => Transform::Rotate0(s.flip().mirror()),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    92
            Transform::Rotate90(s) => Transform::Rotate90(s.flip().mirror()),
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    93
        }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    94
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    95
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    96
    pub fn rotate270(self) -> Transform {
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
    97
        match self {
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    98
            Transform::Rotate0(s) => Transform::Rotate90(s.flip().mirror()),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
    99
            Transform::Rotate90(s) => Transform::Rotate0(s),
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   100
        }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   101
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   102
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   103
    pub fn is_mirrored(&self) -> bool {
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   104
        match self {
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   105
            Transform::Rotate0(s) => s.is_mirrored(),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   106
            Transform::Rotate90(s) => s.is_mirrored(),
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   107
        }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   108
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   109
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   110
    pub fn is_flipped(&self) -> bool {
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   111
        match self {
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   112
            Transform::Rotate0(s) => s.is_flipped(),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   113
            Transform::Rotate90(s) => s.is_flipped(),
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   114
        }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   115
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   116
}
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   117
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   118
#[cfg(test)]
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   119
mod tests {
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   120
    use super::{SymmetryTransform::*, Transform::*, *};
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   121
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   122
    // I totally wrote all of this myself and didn't use ChatGPT
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   123
    #[test]
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   124
    fn test_default() {
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   125
        let rt = Transform::new();
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   126
        assert_eq!(rt, Rotate0(Id));
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   127
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   128
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   129
    #[test]
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   130
    fn test_mirror() {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   131
        let rt = Rotate90(Flip);
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   132
        let mirrored = rt.mirror();
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   133
        assert_eq!(mirrored, Rotate90(Id));
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   134
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   135
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   136
    #[test]
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   137
    fn test_flip() {
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   138
        let rt = Transform::new().rotate180().mirror();
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   139
        let flipped = rt.flip();
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   140
        assert_eq!(flipped, Rotate0(Id));
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   141
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   142
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   143
    #[test]
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   144
    fn test_rotate90() {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   145
        let rt = Rotate0(Id);
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   146
        let rotated = rt.rotate90();
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   147
        assert_eq!(rotated, Rotate90(Id));
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   148
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   149
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   150
    #[test]
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   151
    fn test_rotate180() {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   152
        let rt = Rotate90(Mirror);
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   153
        let rotated = rt.rotate180();
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   154
        assert_eq!(rotated, Rotate90(Flip));
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   155
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   156
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   157
    #[test]
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   158
    fn test_rotate270() {
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   159
        let rt = Transform::new().rotate180().flip();
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   160
        let rotated = rt.rotate270();
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   161
        assert_eq!(rotated, Rotate90(Flip));
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   162
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   163
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   164
    #[test]
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   165
    fn test_rotate180_2() {
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   166
        let rt = Transform::new().rotate180();
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   167
        assert_eq!(rt, Rotate0(FlipMirror));
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   168
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   169
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   170
    #[test]
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   171
    fn test_rotation_chain() {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   172
        assert_eq!(
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   173
            Transform::default(),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   174
            Transform::default()
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   175
                .rotate90()
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   176
                .rotate90()
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   177
                .rotate90()
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   178
                .rotate90()
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   179
        );
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   180
        assert_eq!(
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   181
            Transform::default().rotate90(),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   182
            Transform::default().rotate180().rotate90().rotate180()
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   183
        );
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   184
        assert_eq!(
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   185
            Transform::default().rotate180(),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   186
            Transform::default().rotate180().rotate270().rotate90()
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   187
        );
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   188
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   189
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   190
    #[test]
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   191
    fn test_combinations_chain() {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   192
        assert_eq!(
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   193
            Transform::default(),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   194
            Transform::default().flip().rotate180().flip().rotate180()
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   195
        );
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   196
        assert_eq!(
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   197
            Transform::default(),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   198
            Transform::default()
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   199
                .mirror()
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   200
                .rotate180()
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   201
                .mirror()
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   202
                .rotate180()
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   203
        );
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   204
        assert_eq!(
15918
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   205
            Transform::default(),
9bd828451d77 Fix several issues with transformations, more work on getting generated image
unC0Rr
parents: 15916
diff changeset
   206
            Transform::default().rotate90().flip().rotate90().mirror().rotate180()
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   207
        );
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   208
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff changeset
   209
}