View the code ⇓

CTA: Variation on a theme by Victor Vasarely

int Hue, Saturation, i, j, n, NUM=20;
int Square;

void setup()
{
  size(600,600); frameRate(30); smooth(); 
  noStroke(); colorMode(HSB,360,100,100); 
  n=NUM*NUM; Hue=0; Square=width/NUM;
}

void draw()
{  
  if(n==NUM*NUM){
    n=-1; Hue=(Hue+29)%360;
    Saturation=(int)random(25,100);
    background(Hue,Saturation,50);}  
  i=n%NUM; j=int(n/NUM);
  fill(Hue,Saturation,
     100-200/NUM*max(abs(i-(NUM-1)/2.0),abs(j-(NUM-1)/2.0)));
  ellipse(Square*(0.5+i),Square*(0.5+j),
          Square,Square);
  n++;
}

Return to top ⇑