Functions are an elementary part of programming languages. With them programs can be simplified and presented in a manageable and reusable way (modularisation). Functions also help us to keep our code organised and understandable.
Functions act as jumps in the program. In the event of a function call, the program jumps to the position where the function is defined and then returns after the function has been executed.
In the previous examples we have written programs without functions. These programs were not interactive and do not include animations. So how can you extend a program so that, for example, the keyboard is used as an input? The answer is to use program events, which are recorded and forwarded by the program. Here is a short list of some such events:
...
- void setup ()
- void draw ()
These functions have accept no parameters so the space between the brackets is left blank, and they have no return value , so only the 'void' keyword is replaced by the return typeused. The function names are reserved names that processing Processing knows, so Processing calls these functions as soon as the corresponding event occurs.
...