basic window

This commit is contained in:
Zynh0722 2024-02-22 19:15:07 -08:00
parent 859a8315d6
commit 9ee2679224
3 changed files with 2685 additions and 1 deletions

2655
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -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"

View file

@ -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);
}