Introduction to Programmingusing the Processing languageLecturer: Maarten Lamers of the Media Technology MSc program at Leiden University Teaching assistant: Joris Slob Course developed by Bas Haring (2004) Alterations by Maarten Lamers (2005, 2006, 2007) Introduction Lecture I Lecture II Lecture III Lecture IV Lecture V Lecture VI Lecture VII Fun |
|
Programming concepts |
Functions (or methods) Arguments Return values Scope of variables |
Processing details |
Mouse interaction |
Reserved words |
void abs() max() mouseX mousePressed() return() sq() min() mouseY mouseReleased() strokeWeight() sqrt() ceil() pmouseX mouseMoved() smooth() pow() floor() pmouseY mouseDragged() random() dist() stroke() fill() point() |
Question |
What will next program print? In other words, what is the value of
i after func(i) has been
executed?
|
void setup() {
int i = 7;
func(i);
println(i);
}
void func(int i) {
i = 13;
}
|
|
Remark |
Clear layout of your code makes is much easier to read and understand the structure of your code. For example, indenting code that is 'captured' between the { and } brackets of a function definition makes it easier to see where the function starts and where it ends. Hint: pressing Ctrl-T in the Processing Environment indents your code for you.
|
void setup() {
// you can indent as many spaces as you wish
int m = 28;
func(m);
}
|