From e554dc30d0a2c9863a9ed4838363d24e7c037fe1 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Thu, 3 Jul 2025 13:47:58 +0200 Subject: [PATCH] better grid --- src/bin/render_lines_gui.rs | 12 ++++-------- src/trap/laser.rs | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/bin/render_lines_gui.rs b/src/bin/render_lines_gui.rs index 9024002..ca196fa 100644 --- a/src/bin/render_lines_gui.rs +++ b/src/bin/render_lines_gui.rs @@ -389,15 +389,11 @@ fn laser_frame_producer(model: &mut LaserModel, frame: &mut laser::Frame){ let new_points = model.config.filters.apply(&points); let new_laser_points = new_points.points; - if new_laser_points.len() < pointno { - println!("Cropped Points {} (was: {})", new_laser_points.len(), pointno); - } - - // on reconnect gives Unknown - // dbg!(&model.config); - // dbg!(&points.points[0]); - // dbg!(&new_laser_points[0]); + // if new_laser_points.len() < pointno { + // println!("Cropped Points {} (was: {})", new_laser_points.len(), pointno); + // } + frame.add_lines(new_laser_points); return; } diff --git a/src/trap/laser.rs b/src/trap/laser.rs index f2fd7ee..c58fce4 100644 --- a/src/trap/laser.rs +++ b/src/trap/laser.rs @@ -172,16 +172,22 @@ impl StreamSource{ LaserPoints { points, space: CoordinateSpace::Laser } }, Self::Grid => { + let lines: usize = 5; let mut points = Vec::new(); - for i in (0..=0xFFF).step_by(0xFFF / 5) { + // vertical lines + for i in 0..=lines { + let offset = if i % 2 == 0 { 0 } else {0xFFF } as f32; + let x = i * 0xFFF / lines; points.push(laser::Point{ - position:[i as f32, 0.], + position:[x as f32, offset], color: [0., 0., 0.], weight: 0, }); for j in (0..=0xFFF).step_by(0xFFF / 10) { + // go back and forth, so galvo has it easier + let y = if i % 2 == 0 { j } else {0xFFF - j}; points.push(laser::Point{ - position:[i as f32, j as f32], + position:[x as f32, y as f32], color: [1.,1.,1.], weight: 0, }); @@ -189,15 +195,19 @@ impl StreamSource{ points.push(points[points.len()-1].blanked()); } - for i in (0..=0xFFF).step_by(0xFFF / 5) { + for i in 0..=lines { + let offset = if i % 2 == 0 { 0 } else {0xFFF } as f32; + let y = i * 0xFFF / lines; points.push(laser::Point{ - position:[0., i as f32], + position:[offset, y as f32], color: [0., 0., 0.], weight: 0, }); for j in (0..=0xFFF).step_by(0xFFF / 10) { + // go back and forth, so galvo has it easier + let x = if i % 2 == 0 { j } else {0xFFF - j}; points.push(laser::Point{ - position:[j as f32, i as f32], + position:[x as f32, y as f32], color: [1.,1.,1.], weight: 0, });