Add blank segments frames to reposition lasers between frames
This commit is contained in:
parent
d63396b78e
commit
95b12fe9d1
55
src/main.rs
55
src/main.rs
@ -4,9 +4,9 @@ use anyhow::Result;
|
|||||||
use clap::{app_from_crate, crate_authors, crate_description, crate_name, crate_version, Arg};
|
use clap::{app_from_crate, crate_authors, crate_description, crate_name, crate_version, Arg};
|
||||||
use io::Write;
|
use io::Write;
|
||||||
use lasy::{
|
use lasy::{
|
||||||
euler_graph_to_euler_circuit, interpolate_euler_circuit, point_graph_to_euler_graph,
|
blank_segment_points, euler_graph_to_euler_circuit, interpolate_euler_circuit,
|
||||||
points_to_segments, segments_to_point_graph, Blanked, InterpolationConfig, IsBlank, Lerp,
|
point_graph_to_euler_graph, points_to_segments, segments_to_point_graph, Blanked,
|
||||||
Position, Weight,
|
InterpolationConfig, IsBlank, Lerp, Position, Weight,
|
||||||
};
|
};
|
||||||
|
|
||||||
type InputArrayEntry = (f32, f32, u32);
|
type InputArrayEntry = (f32, f32, u32);
|
||||||
@ -172,14 +172,55 @@ fn main() -> Result<()> {
|
|||||||
.expect("radians-per-point must be a float")
|
.expect("radians-per-point must be a float")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut last_frames = vec![];
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let mut line = String::new();
|
let mut line = String::new();
|
||||||
io::stdin().read_line(&mut line)?;
|
io::stdin().read_line(&mut line)?;
|
||||||
|
|
||||||
serde_json::to_writer(
|
last_frames.push(optimize_line(default_weight, &line, &config)?);
|
||||||
io::stdout(),
|
|
||||||
&optimize_line(default_weight, &line, &config)?,
|
if last_frames.len() == 2 {
|
||||||
)?;
|
let a: Vec<Point> = last_frames
|
||||||
|
.first()
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
.map(|(x, y, color)| Point {
|
||||||
|
x: *x,
|
||||||
|
y: *y,
|
||||||
|
color: *color,
|
||||||
|
weight: default_weight,
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let b: Vec<Point> = last_frames
|
||||||
|
.last()
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
.map(|(x, y, color)| Point {
|
||||||
|
x: *x,
|
||||||
|
y: *y,
|
||||||
|
color: *color,
|
||||||
|
weight: default_weight,
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let c: Vec<InputArrayEntry> = a
|
||||||
|
.into_iter()
|
||||||
|
.zip(b.into_iter())
|
||||||
|
.map(|(a, b)| blank_segment_points(a, b, config.blank_delay_points))
|
||||||
|
.flatten()
|
||||||
|
.map(|p| (p.x, p.y, p.color))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
serde_json::to_writer(io::stdout(), &c)?;
|
||||||
|
io::stdout().write(b"\n")?;
|
||||||
|
io::stdout().flush()?;
|
||||||
|
|
||||||
|
last_frames.remove(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
serde_json::to_writer(io::stdout(), &last_frames.last())?;
|
||||||
io::stdout().write(b"\n")?;
|
io::stdout().write(b"\n")?;
|
||||||
io::stdout().flush()?;
|
io::stdout().flush()?;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user