Nannou: ownership issues

So according to this code:

use nannou::prelude::*;

fn main() {
    nannou::app(model).update(update).run();
}

struct Model {
    _window: window::Id,
}

fn model(app: &App) -> Model {
    let _window = app.new_window().view(view).build().unwrap();
    Model { _window }
}

fn update(_app: &App, _model: &mut Model, _update: Update) {}

fn view(app: &App, _model: &Model, frame: Frame) {
    let draw = app.draw();
    draw.background().color(PLUM);
    draw.ellipse().color(STEELBLUE);
    draw.to_frame(app, &frame).unwrap();
}

Lets just say I have a struct and an impl for a shape. If I were to call initialisation inside the view() function, how would I run it inside the update function? E.g.

fn view(app: &App, _model: &Model, frame: Frame) {
    let draw = app.draw();
    let square = shape::Square::init(); // this has predefined colors, positions and size. The size will be updating
    draw.to_frame(app, &frame).unwrap();
}

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.