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.
...
Code Block | ||
---|---|---|
| ||
function setup(){ createCanvas(300,300); background(0); stroke(255); strokeWeight(10); } function draw(){ point(mouseX, mouseY); } function mousePressed(){ print("x:" + mouseX + ", y:" + mouseY); clear(); background(0); } |
Exercise 4
Write a sketch where a unique shape follows the mouse position. When you click the mouse, the shape should change in some way (form, colour, size).