Function as a parameter

In case you didn’t notice, in the last example we gave functions as parameters for the ellipse-function:

ellipse(random(0, 512), random(0, 512), 50, 50);

We call the ellipse-function and give the random-functions as parameters.

This is often quite handy. When the ellipse-function is called, it first executes the functions in its parameters (functions random(0, 512) and random(0, 512)). After those functions return their values, ellipse function get executed with the new parameters.