Create a GIF with older versions of processing:
https://extrapixel.github.io/gif-animation/
With the latest version of Processing use:
https://processing.org/reference/saveFrame_.html & http://gifmaker.me
The Code:
int largo = 20;
int r = 0;
int g = 0 ;
int b = 0;
void setup() {
size(500,500);
}
void draw()
{
frameRate(12);
for (int x = 0; x < width; x+=45)
{
for (int y = 0; y < height; y+=20) { stroke(255); fill(r,g,b); rect(x,y,largo+45,largo-1); } r +=mouseX+ random(25); g += mouseY+random(25); b += mouseY+random(25); if ( r > 255 )
{
r = 0;
}
if ( g > 255 )
{
g = 0;
}
if ( b > 255 )
{
b = 0;
}
}
saveFrame("random-######.png");
}