A basic sketch that shows how to use millis() for basic animation, in this case a fade-in of a rect(). millis() returns the current runtime of the sketch in milliseconds. Left-click for Fade-In, Right-click for Fade-Out. The transparency (alpha channel of fill/stoke) is calculated evenly across the duration, meaning you only have to change 1 variable (delaytime) for adjusting the speed and fade. I wrote this from scratch as a learning activity some time ago, should be helpful to newcomers.
..continue for code..