Variable resolution
This commit is contained in:
parent
a51fed5026
commit
aae2ecef85
1 changed files with 14 additions and 6 deletions
20
src/main.rs
20
src/main.rs
|
|
@ -30,10 +30,18 @@ fn draw_map(mut query_scene: Single<(&mut Transform, &mut VelloScene)>) {
|
|||
scene.reset();
|
||||
transform.scale = Vec3::ONE * 30.0;
|
||||
|
||||
let grid_size_x = 40;
|
||||
let grid_max_x = grid_size_x / 2;
|
||||
let grid_min_x = -grid_max_x;
|
||||
|
||||
let grid_size_y = 20;
|
||||
let grid_max_y = grid_size_y / 2;
|
||||
let grid_min_y = -grid_max_y;
|
||||
|
||||
let mut rng = rand::rng();
|
||||
let mut points = Vec::new();
|
||||
for x in -20..=20 {
|
||||
for y in -10..=10 {
|
||||
for x in grid_min_x..=grid_max_x {
|
||||
for y in grid_min_y..=grid_max_y {
|
||||
points.push((
|
||||
(x as f64) + rng.random_range(-JITTER..=JITTER),
|
||||
(y as f64) + rng.random_range(-JITTER..=JITTER),
|
||||
|
|
@ -41,8 +49,8 @@ fn draw_map(mut query_scene: Single<(&mut Transform, &mut VelloScene)>) {
|
|||
}
|
||||
}
|
||||
let diagram = VoronoiDiagram::<voronator::delaunator::Point>::from_tuple(
|
||||
&(-20.0, -10.0),
|
||||
&(20.0, 10.0),
|
||||
&(grid_min_x as f64, grid_min_y as f64),
|
||||
&(grid_max_x as f64, grid_max_y as f64),
|
||||
&points,
|
||||
)
|
||||
.unwrap();
|
||||
|
|
@ -65,8 +73,8 @@ fn draw_map(mut query_scene: Single<(&mut Transform, &mut VelloScene)>) {
|
|||
}
|
||||
}
|
||||
|
||||
let nx = (center.x + 20.0) / 40.0 - 0.5;
|
||||
let ny = (center.y + 10.0) / 20.0 - 0.5;
|
||||
let nx = (center.x + grid_max_x as f64) / (grid_size_x as f64) - 0.5;
|
||||
let ny = (center.y + grid_max_y as f64) / (grid_size_y as f64) - 0.5;
|
||||
|
||||
let elevation = (1.0 + noise.get([nx / 0.5, ny / 0.5])) / 2.0;
|
||||
let d = 2.0 * nx.abs().max(ny.abs());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue