Embed a py.processing sketch to the web for easy sharing?

B/c Trinket’s processing module relies on Pjs, and Pjs doesn’t match Processing’s Java Mode fully, not all Processing’s API will be available for it:

Pjs’ API: ProcessingJS.org/reference/

In most cases the shebang isn’t needed at all. More about it:
Trinket.io/faq#what-version-of-python-do-you-use

This forum is now allowing embedded <iframe> tags from some selected hosting sites:

So you can post your sketch here like this:

<iframe src="https://trinket.io/embed/python/973a0f7ae5?toggleCode=true&runOption=run&start=result" width="100%" height="260" frameborder="0" marginwidth="0" marginheight="0" allowfullscreen></iframe>

Which would output this:

I guess both loop() & noLoop() are bugged on Trinket. I get the following:

Exception: noLoop() should be called after run() at <unknown>

Under Processing’s Python Mode, everything needed to run our sketches happen behind the scenes.

But Trinket isn’t Processing. Processing is merely another module among others there.

And in order to kickstart our Processing’s callbacks, such as setup(), draw(), mousePressed(), etc., we have to invoke run() there.

Processing got 2 JS flavors: the old Pjs & the not-so-new p5.js.

Therefore when we write a sketch, we need to choose which 1 of those 2 libraries as API “target”.

B/c even though they’re similar, there are considerable API differences:

1 Like