Increase waterfall size and have it fill the screen

This commit is contained in:
Lucas Schumacher 2024-05-07 19:23:27 -04:00
parent e37eb169ce
commit 63ec587d08
2 changed files with 32 additions and 34 deletions

View File

@ -20,6 +20,8 @@ mod deadbeef_rand {
} }
use deadbeef_rand::rand; use deadbeef_rand::rand;
const WF_SIZE: usize = 1024;
/// We derive Deserialize/Serialize so we can persist app state on shutdown. /// We derive Deserialize/Serialize so we can persist app state on shutdown.
pub struct TemplateApp { pub struct TemplateApp {
// Example stuff: // Example stuff:
@ -49,7 +51,7 @@ impl TemplateApp {
// Example stuff: // Example stuff:
label: "Hello World!".to_owned(), label: "Hello World!".to_owned(),
value: 2.7, value: 2.7,
waterfall: Arc::new(Mutex::new(Waterfall::new(gl, 300, 300, rx))), waterfall: Arc::new(Mutex::new(Waterfall::new(gl, WF_SIZE, WF_SIZE, rx))),
fft_sender: tx, fft_sender: tx,
} }
} }
@ -115,13 +117,17 @@ impl eframe::App for TemplateApp {
ui.label(" (OpenGL)."); ui.label(" (OpenGL).");
}); });
ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| {
powered_by_egui_and_eframe(ui);
egui::warn_if_debug_build(ui);
egui::Frame::canvas(ui.style()).show(ui, |ui| { egui::Frame::canvas(ui.style()).show(ui, |ui| {
let available_space = ui.available_size();
let (rect, response) = let (rect, response) =
ui.allocate_exact_size(egui::Vec2::splat(300.0), egui::Sense::drag()); ui.allocate_exact_size(available_space, egui::Sense::drag());
let _angle = response.drag_motion().x * 0.01; let _angle = response.drag_motion().x * 0.01;
let mut new_data = vec![0_u8; 300]; let mut new_data = vec![0_u8; WF_SIZE];
for data in new_data.iter_mut() { for data in new_data.iter_mut() {
*data = rand(); *data = rand();
} }
@ -140,16 +146,6 @@ impl eframe::App for TemplateApp {
}; };
ui.painter().add(callback); ui.painter().add(callback);
}); });
ui.separator();
ui.add(egui::github_link_file!(
"https://github.com/emilk/eframe_template/blob/main/",
"Source code."
));
ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| {
powered_by_egui_and_eframe(ui);
egui::warn_if_debug_build(ui);
}); });
}); });
} }

View File

@ -119,8 +119,10 @@ impl Waterfall {
// Generate something to put into the texture Buffer // Generate something to put into the texture Buffer
let mut buffer = vec![0; width * height]; let mut buffer = vec![0; width * height];
// Add some stripes to the texture // Add some stripes to the texture
let stripes = 8;
let slen = width / stripes;
for (i, val) in buffer.iter_mut().enumerate() { for (i, val) in buffer.iter_mut().enumerate() {
*val = if i % 50 < 25 { 255 } else { 0 }; *val = if i % slen < slen / 2 { 255 } else { 0 };
//*val = 255; //*val = 255;
} }