Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tools/twix/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "twix"
version = "0.12.0"
version = "0.12.1"
edition.workspace = true
license.workspace = true
homepage.workspace = true
Expand Down
36 changes: 17 additions & 19 deletions tools/twix/src/panels/image_segments.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::Arc;
use std::{iter::once, sync::Arc};

use eframe::{
egui::{ComboBox, Response, Ui, Widget},
Expand All @@ -13,7 +13,7 @@ use serde_json::{json, Value};
use types::{
camera_position::CameraPosition,
color::{Hsv, RgChromaticity, Rgb},
image_segments::{Direction, EdgeType, ImageSegments, Segment},
image_segments::{Direction, EdgeType, ImageSegments, ScanLine, Segment},
};

use crate::{
Expand Down Expand Up @@ -218,16 +218,22 @@ impl Widget for &mut ImageSegmentsPanel {
Direction::Horizontal => image_segments.scan_grid.horizontal_scan_lines,
Direction::Vertical => image_segments.scan_grid.vertical_scan_lines,
};
let max = match self.direction {
Direction::Horizontal => 480,
Direction::Vertical => 640,
};

if let Some([left, right]) = scan_lines.get(0..2) {
let width = (right.position - left.position) as f32 / 2.0;
let position = left.position as f32 + width / 2.0;
for segment in &left.segments {
self.draw_segment(position, width, self.direction, segment, &painter);
}
}

for (left, center, right) in scan_lines.iter().tuple_windows() {
for (left, center, right) in once(ScanLine {
position: 0,
segments: Vec::new(),
})
.chain(scan_lines)
.chain(once(ScanLine {
position: max,
segments: Vec::new(),
}))
.tuple_windows()
{
let start = left.position as f32 + (center.position - left.position) as f32 / 2.0;
let end = center.position as f32 + (right.position - center.position) as f32 / 2.0;
let width = end - start;
Expand All @@ -238,14 +244,6 @@ impl Widget for &mut ImageSegmentsPanel {
}
}

if let Some([left, right]) = scan_lines.windows(2).last() {
let width = (right.position - left.position) as f32 / 2.0;
let position = left.position as f32 + width / 2.0;
for segment in &left.segments {
self.draw_segment(position, width, self.direction, segment, &painter);
}
}

response
}
}
Expand Down