Changing text

This commit is contained in:
Ruben van de Ven 2025-04-08 19:42:23 +02:00
parent a0e5a6777d
commit f20025c513
2 changed files with 21 additions and 10 deletions

View file

@ -11,6 +11,8 @@ use trap::zmqplugin::ZmqPlugin;
use nannou_laser as laser; use nannou_laser as laser;
use std::fs; use std::fs;
use std::time::Instant;
mod trap; mod trap;
fn main() { fn main() {
@ -37,7 +39,7 @@ fn main() {
} }
struct LaserModel{ struct LaserModel{
t: Instant
} }
#[derive(Component)] #[derive(Component)]
@ -51,24 +53,24 @@ fn setup(mut commands: Commands) {
// Spawn a camera for our main window // Spawn a camera for our main window
commands.spawn((render::NannouCamera, RenderLayers::none())); commands.spawn((render::NannouCamera, RenderLayers::none()));
let path = "your_future_points_test.json"; // let path = "your_future_points_test.json";
// let file = File::open(path)?; // let file = File::open(path)?;
let data = fs::read_to_string(path).expect("Unable to read file"); // let data = fs::read_to_string(path).expect("Unable to read file");
// let reader = BufReader::new(file); // let reader = BufReader::new(file);
// let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse"); // let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse");
let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse"); // let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse");
// let max = res[0].iter().cloned().fold(0./0., f64::max); // let max = res[0].iter().cloned().fold(0./0., f64::max);
println!("{}",res); // println!("{}",res);
// let u = serde_json::from_reader(reader)?; // let u = serde_json::from_reader(reader)?;
// Initialise the state that we want to live on the laser thread and spawn the stream. // Initialise the state that we want to live on the laser thread and spawn the stream.
let laser_model = LaserModel { let laser_model = LaserModel {
t: Instant::now()
}; };
let _laser_api = laser::Api::new(); let _laser_api = laser::Api::new();
// dacs = _laser_api.detect_dacs() // dacs = _laser_api.detect_dacs()
@ -101,8 +103,16 @@ fn text2points(position_and_intensity: [f32;3]) -> laser::Point{
fn laser_frame_producer(_laser: &mut LaserModel, frame: &mut laser::Frame){ fn laser_frame_producer(_laser: &mut LaserModel, frame: &mut laser::Frame){
let positions = trap::shapes::YOUR_FUTURE;
let dt = _laser.t.elapsed().as_millis();
let use_second = (dt % 1000) > 500;
let positions = match use_second {
true => trap::shapes::YOUR_FUTURE,
false => trap::shapes::ARE_YOU_SURE,
};
println!("{}, {}" , use_second, dt);
// let tl = [-1.0, 1.0]; // let tl = [-1.0, 1.0];
// let tr = [1.0, 1.0]; // let tr = [1.0, 1.0];
// let br = [1.0, -1.0]; // let br = [1.0, -1.0];

File diff suppressed because one or more lines are too long