accomodated rescaled canvas
Gio e@mail
Sat, 21 Feb 2026 20:41:00 -0500
1 files changed,
10 insertions(+),
8 deletions(-)
jump to
M
src/main.rs
→
src/main.rs
@@ -8,8 +8,9 @@ };
const IMAGE_WIDTH: usize = 200; const IMAGE_HEIGHT: usize = 100; -const SCREEN_WIDTH: f32 = 2000.; -const SCREEN_HEIGHT: f32 = 1000.; +const SCREEN_WIDTH: f32 = 800.; +const SCREEN_HEIGHT: f32 = 400.; +const SCALING: f32 = 4.; const EPS_0: f32 = 1.0; const DT: f32 = 0.1;@@ -28,6 +29,7 @@ App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { resolution: (SCREEN_WIDTH, SCREEN_HEIGHT).into(), + canvas: Some("#sim_canvas".into()), ..default() }), ..default()@@ -251,22 +253,22 @@ for state in user_state {
match state { UserState::SelectPointSource => { if position != vec2(-1., -1.) { - let x = (position.x/10.0)as usize + PML_THICKNESS; - let y = (position.y/10.0)as usize + PML_THICKNESS; + let x = (position.x/SCALING)as usize + PML_THICKNESS; + let y = (position.y/SCALING)as usize + PML_THICKNESS; commands.spawn(PointSource{amplitude: 3.0, omega: 1.0, x, y}); } } UserState::SelectWall => { if position != vec2(-1., -1.) { - let x = (position.x/10.0)as usize + PML_THICKNESS; - let y = (position.y/10.0)as usize + PML_THICKNESS; + let x = (position.x/SCALING)as usize + PML_THICKNESS; + let y = (position.y/SCALING)as usize + PML_THICKNESS; grid.eps[x][y] = 1000.0; } } UserState::SelectFreeSpace => { if position != vec2(-1., -1.) { - let x = (position.x/10.0)as usize + PML_THICKNESS; - let y = (position.y/10.0)as usize + PML_THICKNESS; + let x = (position.x/SCALING)as usize + PML_THICKNESS; + let y = (position.y/SCALING)as usize + PML_THICKNESS; grid.eps[x][y] = 1.0; } }