The first lesson consisted of an explanation of the language Processing,
the Processing IDE (Interactive Development Environment), which is
the editor we work in, and why you should learn programming.
I showed you the basic idea of an instruction and of the syntaxis of
the language. The small program we wrote was:
void setup() {
size(400, 400);
}
void draw() {
background(235,113,123);
ellipse(mouseX, mouseY, mouseX / 2, mouseY / 2);
}
Code explained
The setup function will be called first when you run the program. Here's the place to define the basis of your application. What needs to be done in the first place comes here.The draw function is an eternal loop, which will run continuously until either you quit the program or turn of your computer. Setting the background function in the draw function will make Processing to draw the background each frame, each time it's being called. In other words: every frame of your program will be drawn with a fresh background. If you don't do this, the former frame will be visible also (and the former, and the former, etc.).
Dependent on your program you can do this or not.
Drawing an ellipse expects four parameters. You can find more information about basic shapes in the book, page 28.
Processing comes with some internal variables which are always available. Two of them are mouseX and mouseY. These variables change each frame and represent the position of the mouse pointer.
The semicolon is called statement terminator. It instructs the Processing interpreter that you ended a statement and that it can continue reading a next statement.
Geen opmerkingen:
Een reactie posten