From 308697fe6a08c26344e10bdd0aace355be4edc1e Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Thu, 3 Jul 2025 13:17:30 +0200 Subject: [PATCH] better square --- src/trap/laser.rs | 61 ++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/src/trap/laser.rs b/src/trap/laser.rs index 5af2263..f296473 100644 --- a/src/trap/laser.rs +++ b/src/trap/laser.rs @@ -137,33 +137,40 @@ impl StreamSource{ pub fn get_shape(&self, current_lines: LaserPoints) -> LaserPoints { match self { Self::CurrentLines => current_lines, - Self::Rectangle => LaserPoints { points: vec!( - laser::Point{ - position:[0xFFF as f32, 0xFFF as f32], - color: [1.,1.,1.], - weight: 0, - }, - laser::Point{ - position:[0xFFF as f32, 0.0], - color: [1.,1.,1.], - weight: 0, - }, - laser::Point{ - position:[0.0, 0.0], - color: [1.,1.,1.], - weight: 0, - }, - laser::Point{ - position:[0.0, 0xFFF as f32], - color: [1.,1.,1.], - weight: 0, - }, - laser::Point{ - position:[0xFFF as f32, 0xFFF as f32], - color: [1.,1.,1.], - weight: 0, - }, - ), space: CoordinateSpace::Laser }, + Self::Rectangle => { + let mut points = Vec::new(); + let steps: usize = 10; + for i in (0..=steps).rev()a { + points.push(laser::Point{ + position:[0xFFF as f32, (0xFFF * i / steps) as f32], + color: [1.,1.,1.], + weight: 0, + }); + } + for i in (0..=steps).rev() { + points.push(laser::Point{ + position:[(0xFFF * i / steps) as f32, 0.0], + color: [1.,1.,1.], + weight: 0, + }); + } + for i in 0..=steps { + points.push(laser::Point{ + position:[0.0 , (0xFFF * i / steps) as f32], + color: [1.,1.,1.], + weight: 0, + }); + } + for i in 0..=steps { + points.push(laser::Point{ + position:[(0xFFF * i / steps) as f32 , 0xFFF as f32], + color: [1.,1.,1.], + weight: 0, + }); + } + // dbg!("{:?}", &points); + LaserPoints { points, space: CoordinateSpace::Laser } + }, Self::Grid => { let mut points = Vec::new(); for i in (0..=0xFFF).step_by(0xFFF / 5) {