abey79 / vsvg

Fast and portable tools for plotter users
http://whisk.rs
MIT License
107 stars 12 forks source link

Interactive sketch #98

Open hapiel opened 8 months ago

hapiel commented 8 months ago

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