Processing2JS is a porting tool, to help the porting of Processing apps to P5.js. This is a tool that I created for me and my students, and is provided to the rest of the world as is.
It can primarily be used in three ways:
How it works
If we have the following example in Processing:
I choose Tools/Processing2p5js
- Most Processing 2d graphics
- 1-3d arrays
What does not work
- Anything where the API:s between Processing and p5.js differs
- Fore example if API:s that exists in Processing but not in P5.js
- Or the API-functions is not the same
- In this case it actually works in some instances where I have tried to match processing functions with p5.js functions
Classes in Processing2P5js
Processing2P5js tries to convert Processing classes to ES6 classes. ES6 classes is supported in all modern browsers (not in IE). It seems to work for most cases. The keyword static is not supported.
beginShape … endShape
One special thing is beginShape/endShape. It works in the non-object oriented way for example:
In a more object oriented way when used with createShape() it does not work.
In the context of the webb it is often a good idé to preload pictures for example. LoadImage call that are maid in setup() is automatically moved to preload(). If you explicitly want to move a call to preload you can insert //preload after the statement.
Create exceptioncode to keep a common codebase