From 6e533c9c406b483512c0d3037b4f43f8ec98c9be Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Wed, 10 Jan 2024 17:07:51 -0500 Subject: [PATCH] fix scale in pan example --- sg2d-wgpu/examples/scatter-panning/src/lib.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sg2d-wgpu/examples/scatter-panning/src/lib.rs b/sg2d-wgpu/examples/scatter-panning/src/lib.rs index 317fb06..cb61cf4 100644 --- a/sg2d-wgpu/examples/scatter-panning/src/lib.rs +++ b/sg2d-wgpu/examples/scatter-panning/src/lib.rs @@ -56,7 +56,7 @@ pub async fn run() { let margin = 20.0; let width = inner_width + 2.0 * margin; let height = inner_height + 2.0 * margin; - let scale = 1.0; + let scale = 2.0; let shape = shape_to_path("circle").unwrap(); @@ -65,7 +65,7 @@ pub async fn run() { let mut fill: Vec<[f32; 4]> = Vec::new(); let mut size: Vec = Vec::new(); - let n = 10000; + let n = 100000; for _ in 0..n { x.push(rng.gen::() * inner_width + margin); y.push(rng.gen::() * inner_height + margin); @@ -111,7 +111,15 @@ pub async fn run() { WindowEvent::CursorMoved { device_id, position, modifiers } => { // println!("position: {position:?}"); let scene_graph = make_sg( - width, height, &shape, &x, &y, &fill, &size, position.x as f32 - 100.0, position.y as f32 - 100.0 + width, + height, + &shape, + &x, + &y, + &fill, + &size, + (position.x / scale as f64) as f32 - 100.0, + (position.y / scale as f64) as f32 - 100.0 ); canvas.set_scene(&scene_graph).unwrap(); canvas.window().request_redraw();