Max Patches 11/28
Download here
Comments Off on Max Patches 11/28
Today’s in-class code can be found here.
Processing examples for 9/12 can be found here.
What we’ll go over:
– questions on homework (now due Wed)
– explanation of translate and scale
– subroutines explained more fully (in, out args)
– more about variables (types, final, static, arrays)
– input: mouse, keyboard, audio, time/date
You’ll find today’s example code files here.
Here are some notes about what we’ll be going over in class 9/7:
– print(), println()
– Loops: loop(), for, while, continue
– Conditionals: if/else, switch/case/default/break, ?:
– Relational & Logical Operators
– Creating PDFs. Tutorial link: http://www.processing.org/reference/libraries/pdf/index.html
– if there’s time, touching on Input and Output
void setup() {
// do some great setup stuff
smooth();
size(400, 400);
background(192, 64, 0);
stroke(255);
frameRate(1);
}
void draw() {
int randomX;
int randomY;
// generate random rect starting point
randomX = int(random(400));
randomY = int(random(400));
// generate random rgb value
int r = int(random(256));
int g = int(random(256));
int b = int(random(256));
// draw the rect
stroke(r, g, b);
fill(r, g, b);
rect(randomX, randomY, 20, 20);
}
int lastX = 200; // last x value
int lastY = 200; // last y value
void mousePressed() {
// reset stroke to white
stroke(255);
// draw mouse line
line(lastX, lastY, mouseX, mouseY);
// save our last click point
lastX = mouseX;
lastY = mouseY;
}