Learn creative coding writing simple programs

84. Draw gradients, review functions and image loading

This time we don't introduce new concepts but review previous ones. First we rename a variable to give it a more correct name. Then we convert two global variables into local variables and the program becomes slightly shorter. Next we change the program so instead of just drawing one circular gradient it draws a new one each time we click the screen. For that we see again how functions are declared, and how parameter types must match.
Finally we try loading and displaying an image as a background, so the screen is not so empty when the program starts :)

Tags: load, image, gradient, function, global, local, rename, variable

Code editor

You can make changes to the code below. Then

Questions and comments

Try to stay close to the topic of this episode. Use the Processing forums for help with unrelated Processing projects (or hire me for help ;-)

To indicate that a word in your comment is code, use the `backtick`. Example
  Do `float` and `int` smell similar?
To highlight code blocks, use ```processing and ``` like this:
  void setup() {
    size(600, 600);