rust/theme-editor/src/main.rs
changeset 14090 43d956f41cd4
parent 14054 3185fb34f3b5
child 14098 a8e194ae26e8
equal deleted inserted replaced
14089:30565866db82 14090:43d956f41cd4
     5     pixels::{
     5     pixels::{
     6         PixelFormatEnum, Color
     6         PixelFormatEnum, Color
     7     }
     7     }
     8 };
     8 };
     9 
     9 
    10 use integral_geometry::{Point, Size, Rect};
    10 use integral_geometry::{Point, Size, Rect, Line};
    11 
    11 
    12 use rand::{
    12 use rand::{
    13     thread_rng, RngCore, Rng,
    13     thread_rng, RngCore, Rng,
    14     distributions::uniform::SampleUniform
    14     distributions::uniform::SampleUniform
    15 };
    15 };
    16 
    16 
    17 use landgen::{
    17 use landgen::{
    18     template_based::{
    18     template_based::TemplatedLandGenerator,
    19         OutlineTemplate,
    19     outline_template::OutlineTemplate,
    20         TemplatedLandGenerator
       
    21     },
       
    22     LandGenerator,
    20     LandGenerator,
    23     LandGenerationParameters
    21     LandGenerationParameters
    24 };
    22 };
    25 use land2d::Land2D;
    23 use land2d::Land2D;
    26 use lfprng::LaggedFibonacciPRNG;
    24 use lfprng::LaggedFibonacciPRNG;
    73 
    71 
    74 fn point() -> Point {
    72 fn point() -> Point {
    75     Point::new(rnd(WIDTH as i32), rnd(HEIGHT as i32))
    73     Point::new(rnd(WIDTH as i32), rnd(HEIGHT as i32))
    76 }
    74 }
    77 fn rect() -> Rect {
    75 fn rect() -> Rect {
    78     Rect::new(rnd(WIDTH as i32), rnd(HEIGHT as i32), rnd(128), rnd(128))
    76     Rect::new(rnd(WIDTH as i32), rnd(HEIGHT as i32), rnd(120) + 8, rnd(120) + 8)
    79 }
    77 }
    80 
    78 
    81 fn init_source() -> LandSource<TemplatedLandGenerator> {
    79 fn init_source() -> LandSource<TemplatedLandGenerator> {
    82     let template = OutlineTemplate::new(SIZE)
    80     let template = OutlineTemplate::new(SIZE)
    83         .with_fill_points((0..32).map(|_| point()).collect())
    81         .with_fill_points((0..32).map(|_| point()).collect())
    87     LandSource::new(generator)
    85     LandSource::new(generator)
    88 }
    86 }
    89 
    87 
    90 fn draw_random_lines(land: &mut Land2D<u32>) {
    88 fn draw_random_lines(land: &mut Land2D<u32>) {
    91     for i in 0..32 {
    89     for i in 0..32 {
    92         land.draw_thick_line(point(), point(), rnd(5), u32::max_value());
    90         land.draw_thick_line(Line::new(point(), point()), rnd(5), u32::max_value());
    93 
    91 
    94         land.fill_circle(point(), rnd(60), u32::max_value());
    92         land.fill_circle(point(), rnd(60), u32::max_value());
    95     }
    93     }
    96 }
    94 }
    97 
    95