Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better errs for path #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
20 changes: 14 additions & 6 deletions src/3dneuron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,20 @@ fn view(app: &App, model: &Model, frame: Frame) {
model.egui.draw_to_frame(&frame).unwrap();
}
if app.keys.down.contains(&Key::Space) {
let file_path = app
.project_path()
.expect("failed to locate project directory")
.join("frames")
.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
}
fn vertices_as_bytes(data: &[Vertex]) -> &[u8] {
Expand Down
20 changes: 14 additions & 6 deletions src/asahi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,20 @@ fn view(app: &App, model: &Model, frame: Frame) {
model.egui.draw_to_frame(&frame).unwrap();
}
if app.keys.down.contains(&Key::Space) {
let file_path = app
.project_path()
.expect("failed to locate project directory")
.join("frames")
.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
}
fn vertices_as_bytes(data: &[Vertex]) -> &[u8] {
Expand Down
20 changes: 14 additions & 6 deletions src/asahi2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,20 @@ fn view(app: &App, model: &Model, frame: Frame) {
model.egui.draw_to_frame(&frame).unwrap();
}
if app.keys.down.contains(&Key::Space) {
let file_path = app
.project_path()
.expect("failed to locate project directory")
.join("frames")
.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
}
fn vertices_as_bytes(data: &[Vertex]) -> &[u8] {
Expand Down
20 changes: 14 additions & 6 deletions src/attractors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,20 @@ fn view(app: &App, model: &Model, frame: Frame) {
model.egui.draw_to_frame(&frame).unwrap();
}
if app.keys.down.contains(&Key::Space) {
let file_path = app
.project_path()
.expect("failed to locate project directory")
.join("frames")
.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
}
fn raw_window_event(_app: &App, model: &mut Model, event: &nannou::winit::event::WindowEvent) {
Expand Down
23 changes: 15 additions & 8 deletions src/bhole.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,19 @@ fn v(app: &App, m: &M, f: Frame) {
m.egui.draw_to_frame(&f).unwrap();
}
if app.keys.down.contains(&Key::Space) {
let file_path = app
.project_path()
.expect("failed to locate project directory")
.join("frames")
.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);

}
match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
}
22 changes: 15 additions & 7 deletions src/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,23 @@ fn view(app: &App, model: &Model, frame: Frame) {
.stroke_weight(2.0)
.stroke(BLACK);
}
draw.to_frame(app, &frame).unwrap();
if app.keys.down.contains(&Key::Space) {
let file_path = app
.project_path()
.expect("failed to locate project directory")
.join("frames")
.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
draw.to_frame(app, &frame).unwrap();
if model.settings.show_ui {
model.egui.draw_to_frame(&frame).unwrap();
}
Expand Down
16 changes: 16 additions & 0 deletions src/butter2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ fn view(app: &App, model: &Model, frame: Frame) {
draw.texture(texture);
}
draw.to_frame(app, &frame).unwrap();
if app.keys.down.contains(&Key::Space) {
match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
if model.settings.show_ui {
model.egui.draw_to_frame(&frame).unwrap();
}
Expand Down
24 changes: 16 additions & 8 deletions src/cafe_wall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn model(app: &App) -> Model {
fn update(_app: &App, model: &mut Model, _update: Update) {
model.time = _app.time;
let egui = &mut model.egui;
let _settings = &model.settings;
let _settings: &Settings = &model.settings;
if _app.keys.down.contains(&Key::H) {
model.settings.show_ui = !model.settings.show_ui;
}
Expand Down Expand Up @@ -104,13 +104,21 @@ fn view(app: &App, model: &Model, frame: Frame) {
model.egui.draw_to_frame(&frame).unwrap();
}
if app.keys.down.contains(&Key::Space) {
let file_path = app
.project_path()
.expect("failed to locate project directory")
.join("frames")
.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
}
match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
}
fn raw_window_event(_app: &App, model: &mut Model, event: &nannou::winit::event::WindowEvent) {
model.egui.handle_raw_event(event);
Expand Down
21 changes: 14 additions & 7 deletions src/chladni.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,20 @@ fn view(app: &App, model: &Model, frame: Frame) {
model.egui.draw_to_frame(&frame).unwrap();
}
if app.keys.down.contains(&Key::Space) {
let file_path = app
.project_path()
.expect("failed to locate project directory")
.join("frames")
.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);

match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
}

Expand Down
22 changes: 15 additions & 7 deletions src/chladniwgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,21 @@ fn view(app: &App, model: &Model, frame: Frame) {
model.egui.draw_to_frame(&frame).unwrap();
}
if app.keys.down.contains(&Key::Space) {
let file_path = app
.project_path()
.expect("failed to locate project directory")
.join("frames")
.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
}
match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
}
fn vertices_as_bytes(data: &[Vertex]) -> &[u8] {
unsafe { wgpu::bytes::from_slice(data) }
Expand Down
20 changes: 14 additions & 6 deletions src/cliff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,20 @@ fn view(app: &App, model: &Model, frame: Frame) {
model.egui.draw_to_frame(&frame).unwrap();
}
if app.keys.down.contains(&Key::Space) {
let file_path = app
.project_path()
.expect("failed to locate project directory")
.join("frames")
.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
}

Expand Down
22 changes: 15 additions & 7 deletions src/darkclouds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,21 @@ fn view(app: &App, model: &Model, frame: Frame) {
model.egui.draw_to_frame(&frame).unwrap();
}
if app.keys.down.contains(&Key::Space) {
let file_path = app
.project_path()
.expect("failed to locate project directory")
.join("frames")
.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
}
match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
}
fn vertices_as_bytes(data: &[Vertex]) -> &[u8] {
unsafe { wgpu::bytes::from_slice(data) }
Expand Down
20 changes: 14 additions & 6 deletions src/dfft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,20 @@ fn view(app: &App, model: &Model, frame: Frame) {
model.egui.draw_to_frame(&frame).unwrap();
}
if app.keys.down.contains(&Key::Space) {
let file_path = app
.project_path()
.expect("failed to locate project directory")
.join("frames")
.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
}
fn draw_user_input(draw: &Draw, points: &[Point2], drawing_method: DrawingMethod) {
Expand Down
22 changes: 15 additions & 7 deletions src/enigma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,21 @@ fn view(app: &App, model: &Model, frame: Frame) {
model.egui.draw_to_frame(&frame).unwrap();
}
if app.keys.down.contains(&Key::Space) {
let file_path = app
.project_path()
.expect("failed to locate project directory")
.join("frames")
.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
}
match app.project_path() {
Ok(project_path) => {
let frames_path = project_path.join("frames");
if let Err(e) = std::fs::create_dir_all(&frames_path) {
eprintln!("Failed to create frames directory: {:?}", e);
return;
}
let file_path = frames_path.join(format!("{:0}.png", app.elapsed_frames()));
app.main_window().capture_frame(file_path);
},
Err(e) => {
eprintln!("Failed to locate project directory: {:?}", e);
}
}
}
}
fn raw_window_event(_app: &App, model: &mut Model, event: &nannou::winit::event::WindowEvent) {
model.egui.handle_raw_event(event);
Expand Down
Loading
Loading