Processing Workshop. 2 – Cheat Sheet

Programming, Workshop
Screen Shot 2014-11-09 at 15.06.48

Code for generating random circles 

Basic Structure

void setup ( ) { //runs once only

}

void draw ( ) { //runs repeatedly during the execution.

}

Variable Types

Int, positive and negative integer variables

Float, floating point positive and negative variables

Boolean, variables that can be true or false

Basic Functions

println ( )

size (width, height), sets main window size

background (colour), sets window background colour

Variables

width

height

mouseX

mouseY

Conditional Structure

if (condition1) {

} else if (condition2) {

} else {

}

< less than

<= less than or equal to

== equal

> greater than

>= greater than or equal to

!= not equal

&& and

|| or

! not

Loops

For loop:

for (int i=0; i<10; i++){

//do whatever we want repeated

}

Arrays

Fill/ Stroke

fill (colour); sets the colour used to fill shapes

noFill ( );

stroke (colour); sets the colour used to draw strokes around the shapes

noStroke ( );

Colour

Value scale foes from 0 to 255

colour (grayscale);

colour (grayscale, alpha);

colour (red, green, blue);

colour (red, green, blue, alpha);

ellipse (posx, posy, width, height);

rect (posx, posy, width, height);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s