p5 icon indicating copy to clipboard operation
p5 copied to clipboard

Sketch w/o event function

Open redfood opened this issue 7 years ago • 0 comments

Is your feature request related to a problem? Please describe.

Processing lets you write sketches w/o defining event functions like setup, draw, etc.

So, in processing, you can write the following:

size(200,200)
ellipse(100,100, 50, 50)

And you get a window with a circle in the middle.

This style of programming is great for beginners creating non-interactive algorithmic art.

Describe the solution you'd like It would be nice is p5.py supported the same style of imperative non-event-based programming. It would also be nice if this solution allowed for using p5.py in the REPL. e.g.

>>> import p5
>>> p5.size(200,200)
>>> p5.ellipse(100,100, 50, 50)

Describe alternatives you've considered I've considered writing a pre-processor that looks at the python/sketch file, pulls out the call to size, puts it in setup with a call to no_loop, then places the rest of the statements in draw, with a call to run in the end. This, of course, is hacky and doesn't allow the use of the Python REPL.

A better solution would be for size, if called before run, to start a sketch and return control. Then for all the p5 calls to operate on that sketch. (I realize this may cause architectural changes and/or threading issues).

redfood avatar Dec 17 '18 18:12 redfood