rust/theme-editor/src/main.rs
changeset 14102 c6923ce139a2
parent 14099 7845beb87cb5
child 14123 59ec51b78737
equal deleted inserted replaced
14101:ceda58e398e0 14102:c6923ce139a2
   125     OutlineTemplate::new(PLAY_SIZE)
   125     OutlineTemplate::new(PLAY_SIZE)
   126         .add_island(&island)
   126         .add_island(&island)
   127         .add_fill_points(&[Point::new(1023, 0)])
   127         .add_fill_points(&[Point::new(1023, 0)])
   128 }
   128 }
   129 
   129 
   130 
       
   131 fn init_source() -> LandSource<TemplatedLandGenerator> {
   130 fn init_source() -> LandSource<TemplatedLandGenerator> {
   132     let template = test_template();
   131     let template = test_template();
   133     let generator = TemplatedLandGenerator::new(template);
   132     let generator = TemplatedLandGenerator::new(template);
   134     LandSource::new(generator)
   133     LandSource::new(generator)
       
   134 }
       
   135 
       
   136 fn draw_center_mark(land: &mut Land2D<u32>) {
       
   137     for i in 0..32 {
       
   138         land.draw_thick_line(Line::new(Point::new(LAND_WIDTH as i32 / 2, 0),
       
   139                                        Point::new(LAND_WIDTH as i32 / 2, LAND_HEIGHT as i32)), 10, 128);
       
   140         land.draw_thick_line(Line::new(Point::new(0, LAND_HEIGHT as i32 / 2),
       
   141                                        Point::new(LAND_WIDTH as i32, LAND_HEIGHT as i32 / 2)), 10, 128);
       
   142         land.fill_circle(Point::new(LAND_WIDTH as i32, LAND_HEIGHT as i32) / 2, 60, 128);
       
   143     }
   135 }
   144 }
   136 
   145 
   137 fn draw_random_lines(land: &mut Land2D<u32>) {
   146 fn draw_random_lines(land: &mut Land2D<u32>) {
   138     for i in 0..32 {
   147     for i in 0..32 {
   139         land.draw_thick_line(Line::new(point(), point()), rnd(5), 128);
   148         land.draw_thick_line(Line::new(point(), point()), rnd(5), 128);
   154         .build().unwrap();
   163         .build().unwrap();
   155 
   164 
   156     let mut source = init_source();
   165     let mut source = init_source();
   157     let mut land = source.next(
   166     let mut land = source.next(
   158         LandGenerationParameters::new(0, u32::max_value()));
   167         LandGenerationParameters::new(0, u32::max_value()));
   159     draw_random_lines(&mut land);
   168     draw_center_mark(&mut land);
   160 
       
   161 
   169 
   162     let mut land_surf = Surface::new(LAND_WIDTH, LAND_HEIGHT, PixelFormatEnum::ARGB8888).unwrap();
   170     let mut land_surf = Surface::new(LAND_WIDTH, LAND_HEIGHT, PixelFormatEnum::ARGB8888).unwrap();
   163 
   171 
   164     fill_texture(&mut land_surf, &land);
   172     fill_texture(&mut land_surf, &land);
   165 
   173