basic window
parent
859a8315d6
commit
9ee2679224
File diff suppressed because it is too large
Load Diff
|
@ -6,3 +6,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
nannou = "0.19.0"
|
||||
|
|
30
src/main.rs
30
src/main.rs
|
@ -1,3 +1,31 @@
|
|||
use nannou::prelude::*;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
nannou::app(model).run();
|
||||
}
|
||||
|
||||
struct Model {
|
||||
// Store the window ID so we can refer to this specific window later if needed.
|
||||
_window: WindowId,
|
||||
}
|
||||
|
||||
fn model(app: &App) -> Model {
|
||||
// Create a new window! Store the ID so we can refer to it later.
|
||||
let _window = app
|
||||
.new_window()
|
||||
.size(512, 512)
|
||||
.title("nannou")
|
||||
.view(view) // The function that will be called for presenting graphics to a frame.
|
||||
.event(event) // The function that will be called when the window receives events.
|
||||
.build()
|
||||
.unwrap();
|
||||
Model { _window }
|
||||
}
|
||||
|
||||
// Handle events related to the window and update the model if necessary
|
||||
fn event(_app: &App, _model: &mut Model, _event: WindowEvent) {}
|
||||
|
||||
// Draw the state of your `Model` into the given `Frame` here.
|
||||
fn view(_app: &App, _model: &Model, frame: Frame) {
|
||||
frame.clear(CORNFLOWERBLUE);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue