Changing Scale

If you are in a situation that you need to blow up the size of already designed processing file, you can change the size very easily.
So for example, if you want to scale your file 200 percent,
size(250,250) would change to size(500,500) and add scale(2.0); in front of the very first shape or line.

Programming Tips

If you come across any helpful code snippets for programming with Processing, you can add them here. Include visual examples and the code with some explanation.


Variables are containers for values that can be stored and used at anytime when a program is running. They can be changed easily and this helps avoid unnecessary repetition in coding. There are basically two parts to declaring a variable; the data type and the value. There a few different data types in Processing but for now lets stick to two of the most common; int and float. Integers are whole numbers while floats can have decimals.

int y = 3; // this declares y an integer variable and assigns it a value of 3
float x = 6.5 // this declares x a float variable and assigns it a value of 6.5



Loops are essentially bits of code that allow you repeat the line more than once throughout your program. This makes things more efficient and easier to change if you want to adjust something. A for loop has 3 parts to it: intialization, test and update. This is always followed by a set of opening and closing braces which contain the statement or block
for {initialize; test; update) {
If we create a loop, it starts by initializing a value using a variable (i is often used but for no particular reason) , then checks the value of that variable and, finally changes the variables value by updating it. In the code below, the initial variable is set at a value of 20. Next it's value is checked to to make sure it is less than 400. If this is true, 8 is added to the variable's value. This will repeat until the test returns a false value, meaning the loop stops. I
for( i=20; i<400; i+=8)
In this way a repeating pattern can created in one line rather than writing a lot of lines of code. Much more efficient and easier to manage!


Relational Operators

Used when comparing or checking a value
>    greater than
<    less than
>=   greater or qual
<=   less or equal
==   equal to // eg. x==2 checking if x is equal to 2
!=   not equal

Arithmetic Operators

Use for simple arithmetic .
+  plus
-  minus
*  times
/  divided
=  assignment
Sometimes people think that to code you have to be good at mathematics, when in fact a little bit of simple arithmetic covers most of what we will do in this class.