diff --git a/src/bin/render_lines_gui.rs b/src/bin/render_lines_gui.rs index 310ed4a..3b1e117 100644 --- a/src/bin/render_lines_gui.rs +++ b/src/bin/render_lines_gui.rs @@ -890,9 +890,9 @@ fn view_line_canvas(app: &App, model: &GuiModel, frame: Frame) { // show each configured laser in the canvas. Highlight the selected. for (dac_id, config) in model.per_laser_config.iter() { - let rect = shape_rect(LaserSpace::READY); + let rect = shape_rect(LaserSpace::READY, 11); let points = config.filters.reverse(&rect); - + let vertices = points.points.iter().map(|p| { @@ -910,9 +910,24 @@ fn view_line_canvas(app: &App, model: &GuiModel, frame: Frame) { }); draw.polyline() - .weight(thickness) - .join_round() - .points_colored(vertices); + .weight(thickness) + .join_round() + .points_colored(vertices); + + // draggable corners for the selected area + if model.selected_stream == Some(dac_id.clone()){ + let rect = shape_rect(LaserSpace::READY, 1); // find corners + let points = config.filters.reverse(&rect); + for p in points.points { + let pos = [p.position[0] * scale + translate_x, p.position[1] * -scale + translate_y]; + + draw.ellipse() + .x_y(pos[0], pos[1]) + .radius(3.) + .color(srgba(229./255.,45./255.,159./255.,0.8)); + + } + } } diff --git a/src/trap/laser.rs b/src/trap/laser.rs index a830062..c769345 100644 --- a/src/trap/laser.rs +++ b/src/trap/laser.rs @@ -169,36 +169,36 @@ pub enum LaserSpace { READY, } -pub fn shape_rect(space: LaserSpace) -> LaserPoints { +pub fn shape_rect(space: LaserSpace, steps: usize) -> LaserPoints { let offset: f32 = match space { LaserSpace::OLD => 0., _ => 1. }; let factor: f32 = match space { LaserSpace::OLD => 1., _ => 2./0xFFF as f32 }; let mut points = Vec::new(); - let steps: usize = 10; + // let steps: usize = 10; for i in (0..=steps).rev() { points.push(laser::Point{ position:[0xFFF as f32 * factor - offset, (0xFFF * i / steps) as f32 * factor - offset], - color: [1.,1.,1.], + color: [0.2,0.2,0.2], weight: 0, }); } - for i in (0..=steps).rev() { + for i in (0..steps).rev() { points.push(laser::Point{ position:[(0xFFF * i / steps) as f32 * factor - offset, 0.0 * factor - offset], - color: [1.,1.,1.], + color: [0.2,0.2,0.2], weight: 0, }); } - for i in 0..=steps { + for i in 0..steps { points.push(laser::Point{ position:[0.0 * factor - offset, (0xFFF * i / steps) as f32 * factor - offset], - color: [1.,1.,1.], + color: [0.2,0.2,0.2], weight: 0, }); } for i in 0..=steps { points.push(laser::Point{ position:[(0xFFF * i / steps) as f32 * factor - offset , 0xFFF as f32 * factor - offset], - color: [1.,1.,1.], + color: [0.2,0.2,0.2], weight: 0, }); } @@ -212,17 +212,18 @@ impl StreamSource{ match self { Self::CurrentLines => current_lines, Self::Rectangle => { - shape_rect(LaserSpace::OLD) + shape_rect(LaserSpace::READY, 11) }, Self::Grid => { let lines: usize = 5; + let half = (0xFFF / 2) as f32; let mut points = Vec::new(); // 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:[x as f32, offset], + position:[(x as f32 - half) / half, (offset as f32 - half)/half], color: [0., 0., 0.], weight: 0, }); @@ -230,7 +231,7 @@ impl StreamSource{ // go back and forth, so galvo has it easier let y = if i % 2 == 0 { j } else {0xFFF - j}; points.push(laser::Point{ - position:[x as f32, y as f32], + position:[(x as f32 - half)/half, (y as f32 - half)/half], color: [1.,1.,1.], weight: 0, }); @@ -242,7 +243,7 @@ impl StreamSource{ let offset = if i % 2 == 0 { 0 } else {0xFFF } as f32; let y = i * 0xFFF / lines; points.push(laser::Point{ - position:[offset, y as f32], + position:[(offset as f32 - half)/half, (y as f32 - half)/half], color: [0., 0., 0.], weight: 0, }); @@ -250,7 +251,7 @@ impl StreamSource{ // go back and forth, so galvo has it easier let x = if i % 2 == 0 { j } else {0xFFF - j}; points.push(laser::Point{ - position:[x as f32, y as f32], + position:[(x as f32 - half)/half, (y as f32 - half)/half], color: [1.,1.,1.], weight: 0, });