Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

deutsche Version

Syntax of functions

There are two parts of a function. First there is the the function declaration, where the name of the function along with its properties and behaviors are defined. Next there is the function call, where the function is then actually executed. Functions may be called multiple times.

...

Functions can also return a value. This means when we return to the line where the function was called, it has now carried a number with it. In processing, functions that have no return value are declared with “void” return type.


Function Declaration

This is how the function is named, its return type and parameters defined with sudo code.

...

functionName(parameter,.....) ;

...


Function Examples

This example shows how to write functions with return values.

...

Code Block
void setup()
{
  size(300,300);
  background(0);
}
 
void draw()
{}
 
void mousePressed()
{
  println("x:" + mouseX + ", y:" + mouseY);
}


Exercise 3

Create a program where a unique shape follows the mouse position.

...