Processing Uses Java. Here Are Some Important Java/Python Differences: 1. Coding Syntax (What You Type)
Processing Uses Java. Here Are Some Important Java/Python Differences: 1. Coding Syntax (What You Type)
Processing Uses Java. Here Are Some Important Java/Python Differences: 1. Coding Syntax (What You Type)
Example:
void draw()
{
// print the integers from 1 to 9
for (int i = 1; i < 10; i++) // set up the for loop with an i integer
{
println(i); // output i to the console
}
}
String hello = 5;
Processing will highlight that line and tell you that you can’t convert from an int to a
String.
void setup()
{
frogs = 99;
// a local variable that only exists inside this function
String hello = “hello, world!”;
}
void draw()
{
frogs += 99; // we can access the frogs variable here
// this will give an error (cannot find anything named “hello”)
// because the hello variable
// only exists inside the setup function!
hello = “burp”;
}
The exception to this are special Processing global variables, which basically means
variables you can access anywhere. Really useful Processing ones are width and
height, which after the size() method has been called hold the width and height
info for the sketch. Take a look at the pink cheatsheet to see some others.
Comments
Comments are ignored by Processing, but they are really handy for making notes to
yourself about what you are trying to do, or for what a variable is for. You’ll see a
lot of comments in the code today!
Cannot find anything called “x” Processing can’t find the x variable. Is it in scope
(see above)?
The function somefunction() Processing can’t find the function you refer to. Is
does not exist there a typo in your function call?
The method method(x,y) is not You are calling that method incorrectly! Check in
applicable for the the reference to see what data you need to
arguments(a,b). specify in the brackets.