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

Interactive sketch #98

Open
hapiel opened this issue Jan 4, 2024 · 0 comments
Open

Interactive sketch #98

hapiel opened this issue Jan 4, 2024 · 0 comments

Comments

@hapiel
Copy link
Contributor

hapiel commented Jan 4, 2024

It would be fun to have sketches interactive, to be able to use input from the mouse or keyboard.

This could be very basic, such as something like:

`
let mut x = 0; // somehow persist these values between updates
let mut y = 0;

impl App for MySketch {

fn update(&mut self, sketch: &mut Sketch, _ctx: &mut Context) -> anyhow::Result<()> {

    if mouse::is_pressed() {
        x = mouse::x();
        y = mouse::y();
    }
    sketch
        .circle(x, y, 10);

    Ok(())
}

}`

In this case of course the mouse pixel coordinates need to be converted to a value that is independent of zoom level.

But of course, a next step would be to have some kind of cumulative canvas. So that I can draw lines with my mouse, for example. This would be similar to processing, where each layer is rendered upon the previous layer. Of course this brings up questions, such as should it be possible to overlap lines, and whatnot. But I very much enjoyed in processing that I could easily create my own drawing applications, a kind of co-creative system.

Ultimately I guess that this kind of interaction would allow people to create games and whatnot, which can be paused at any moment to create plots. Not very different from your rusteroids ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant