Skip to content

Interactive sketch #98

@hapiel

Description

@hapiel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions