rust/landgen/src/lib.rs
author Wuzzy <Wuzzy2@mail.ru>
Mon, 26 Nov 2018 21:10:33 +0100
changeset 14308 2978d6405d88
parent 14212 bb2f301d4fe0
permissions -rw-r--r--
Backed out changeset 8d2983ff939b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14105
4d22be35cfa2 Finish porting FindPoint()
unc0rr
parents: 14074
diff changeset
     1
mod outline;
14074
abb42ba345b6 Rework lib structure, no code changes
unC0Rr
parents: 14059
diff changeset
     2
pub mod outline_template;
14105
4d22be35cfa2 Finish porting FindPoint()
unc0rr
parents: 14074
diff changeset
     3
pub mod template_based;
13913
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
     4
14032
cef0c685fda8 make useful stuff public
alfadur
parents: 14031
diff changeset
     5
pub struct LandGenerationParameters<T> {
14031
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13943
diff changeset
     6
    zero: T,
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13943
diff changeset
     7
    basic: T,
14105
4d22be35cfa2 Finish porting FindPoint()
unc0rr
parents: 14074
diff changeset
     8
    distance_divisor: u32,
14126
69db1d2e4cec land_dump app for testing templated landgen
unc0rr
parents: 14105
diff changeset
     9
    skip_distort: bool,
69db1d2e4cec land_dump app for testing templated landgen
unc0rr
parents: 14105
diff changeset
    10
    skip_bezier: bool,
14031
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13943
diff changeset
    11
}
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13943
diff changeset
    12
14105
4d22be35cfa2 Finish porting FindPoint()
unc0rr
parents: 14074
diff changeset
    13
impl<T: Copy + PartialEq> LandGenerationParameters<T> {
14126
69db1d2e4cec land_dump app for testing templated landgen
unc0rr
parents: 14105
diff changeset
    14
    pub fn new(zero: T, basic: T, distance_divisor: u32, skip_distort: bool, skip_bezier: bool) -> Self {
14105
4d22be35cfa2 Finish porting FindPoint()
unc0rr
parents: 14074
diff changeset
    15
        Self {
4d22be35cfa2 Finish porting FindPoint()
unc0rr
parents: 14074
diff changeset
    16
            zero,
4d22be35cfa2 Finish porting FindPoint()
unc0rr
parents: 14074
diff changeset
    17
            basic,
14126
69db1d2e4cec land_dump app for testing templated landgen
unc0rr
parents: 14105
diff changeset
    18
            distance_divisor,
69db1d2e4cec land_dump app for testing templated landgen
unc0rr
parents: 14105
diff changeset
    19
            skip_distort,
69db1d2e4cec land_dump app for testing templated landgen
unc0rr
parents: 14105
diff changeset
    20
            skip_bezier,
14105
4d22be35cfa2 Finish porting FindPoint()
unc0rr
parents: 14074
diff changeset
    21
        }
14059
3185fb34f3b5 update theme editor to use new land generator implementation
alfadur
parents: 14056
diff changeset
    22
    }
3185fb34f3b5 update theme editor to use new land generator implementation
alfadur
parents: 14056
diff changeset
    23
}
3185fb34f3b5 update theme editor to use new land generator implementation
alfadur
parents: 14056
diff changeset
    24
14032
cef0c685fda8 make useful stuff public
alfadur
parents: 14031
diff changeset
    25
pub trait LandGenerator {
14031
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13943
diff changeset
    26
    fn generate_land<T: Copy + PartialEq, I: Iterator<Item = u32>>(
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13943
diff changeset
    27
        &self,
14126
69db1d2e4cec land_dump app for testing templated landgen
unc0rr
parents: 14105
diff changeset
    28
        parameters: &LandGenerationParameters<T>,
14031
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13943
diff changeset
    29
        random_numbers: &mut I,
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13943
diff changeset
    30
    ) -> land2d::Land2D<T>;
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13943
diff changeset
    31
}
13943
1fa905aa4cdb move point struct into integral-geometry and use it to refactor a bit
alfadur
parents: 13913
diff changeset
    32
13913
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    33
#[cfg(test)]
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    34
mod tests {
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    35
    #[test]
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    36
    fn it_works() {
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    37
        assert_eq!(2 + 2, 4);
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    38
    }
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    39
}