We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello.
I'm completely fresh in this p5 thing. I'm learning with these tutorials from one of p5 creators. I know that p5 is mixed with javascript but i don´t understand how can we simply use js in a skectch instead of p5 syntax. For example, when i try to run the code in the video below, nothing happens (i'm using Atom editor). Can you help me understand this?
Answers
Processing allows for various modes, from R to Python to Javascript. More Javascript functionality is added through the p5.js library. It would be best if you used the Processing IDE and installed the p5.js mode. This way, the program layout is already set up for you, so you won't have to do it from scratch.
If you don't run the program from the Processing IDE and want to stick with Atom, make sure to reference it in your HTML file like so:
You can also create the sketch directly in the script tag.
Also, if you are new to p5.js, objects should be learned later on. Check out some resources here.
You can also, instead of downloading and referencing the p5.js library from a local folder, reference it from an online repo like this:
https://cdnjs.com/libraries/p5.js/
For instance, check @GoToLoop's post here: https://forum.processing.org/two/discussion/comment/108529/#Comment_108529
Kf
@vasques -- re:
That isn't quite right. From the p5.js homepage:
So it isn't "mixed with JavaScript" -- it is JavaScript, but using most of the same core API as Processing Java (setup, draw, line, rect, etc).
Other modes each allow writing sketches in those languages, not in a mixture of that language and Java -- Processing.py (Python mode) involves writing sketches in Python, Processing.R (R mode) involves writing sketches in R. These modes then running on a Java platform behind-the-scenes so that they can work with the Processing Java implementation. For example, Processing.py runs on Jython:
...and Processing.R runs on Renjin: