Hello,
it took me Covid confinement to eventually start developing the little hitch-hiking mini-game I had in mind!
I turned to Processing to develop it quickly (involves a moving car with random color, and a pedestrian which has to indicate a matching color (= direction) to be allowed onboard the car --> easily done in Processing).
I do not code and am currently learning Python in order to work as a data scientist, and thus chose the Python mode of Processing to code my mini-game.
I am now happy with the result and would like to embed the prototype on a webpage (can be on a public gallery like openprocessing or similar) and was wondering what the quickest solution was…
I am sure translating my Python code to P5JS and then putting my P5JS code on Open Processing works but… it requires me to learn P5JS (and do not know JS).
Thanks GoToLoop, I understand from your answer that trinket.io is the way to go.
I’ll copy-paste my Python code there and it will generate the sketch on the same webpage
For future projects where I’ll want to embed sketches directly into webpages, I assume I’ll have to switch to p5.js…
I guess I can manage to learn 2 languages (Python and JS), especially if I know they’ll be the only ones I’ll need
Alternatively, you can also target the old Processing.js (Pjs) flavor, which can deal w/ Processing sketches written in both Java & JS syntaxes: ProcessingJS.org/learning
That’s an excellent decision: JS is ubiquitous b/c it’s present in every browser.
MDN has excellent tutorials & references for the JS language btW:
However, given you’re still learning Python, learning another language w/ very diff. syntax at the same time can be daunting.
How about some other language that is very close to Python and is directly transpiled to JS?
Meet CoffeeScript.org.
By using CoffeeScript, you end up learning JS at the same time, given that its JS compiled output is very close to the original code, and you can compare both very easily.
In short, CoffeeScript is similar to Python/Ruby syntaxes the same way JS is similar to Java/C.
Had to adapt the code a little (circle and square --> ellipse and rect, added stuff I saw in your sketch: initial lines - incl. shebang -, final run()) for it to work on Trinket but voilĂ https://trinket.io/python/973a0f7ae5?runOption=run
Loop() (enables car speed modification) does not seem to work now that run() has been added. I couldn’t find any documentation about run(), I assume it’s a trinket specific method
Regarding your advice for the next “tools choice” step, yes I heard about Coffeescript a few years ago, will look into using it instead of JS to ease the learning curve
As regards to P5.js vs Pjs, I do not yet truly understand pros and cons of both choices, but should surely find comparisons online.
Vocabulary question: what do you mean by “target/ing”?
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: