K0F_2022/02-unor/cpu/cpu.pde
/**
Coded by Kof @ 
Sat Feb 26 04:40:38 PM CET 2022
\n\n
   ,dPYb,                  ,dPYb,
   IP'`Yb                  IP'`Yb
   I8  8I                  I8  8I
   I8  8bgg,               I8  8'
   I8 dP" "8    ,ggggg,    I8 dP
   I8d8bggP"   dP"  "Y8ggg I8dP
   I8P' "Yb,  i8'    ,8I   I8P
  ,d8    `Yb,,d8,   ,d8'  ,d8b,_
  88P      Y8P"Y8888P"    PI8"8888
                           I8 `8,
                           I8  `8,
                           I8   8I
                           I8   8I
                           I8, ,8'
                            "Y8P'

*/


Combination comb;
boolean RENDER = false;
float W;

void setup(){
  size(480,360);
  W = width/48.0;
  comb = new Combination();

  textFont(createFont("Semplice Regular",8,false));

  rectMode(CENTER);
}


void draw(){

  comb.draw();

  if(RENDER){
    saveFrame("frame#####.png");
  }
}




//////////////////////////////////////

class Combination{
  boolean[] set;
  boolean active;
  double val;
  float time;

  Combination(){
    set = new boolean[48];
    active = false;
    val = 0;
    time = 0;

    randomize();
  }

  void opak(){
    for(int i = 0 ; i < set.length; i++){
      set[i] = !set[i];   
    }
  }

  void randomize(){
    for(int i = 0 ; i < set.length; i++){
      set[i] = random(255)>127?true:false;
    }
  }

  void draw(){
    noStroke();

    if(frameCount%3==0)
      comb.randomize();
    else
      comb.opak();

    for(int i = 0; i< set.length;i++){
      fill(set[i]?255:0);
      rect(map(i,0,set.length,width/2-W,width/2+W),height/2,1,W);
    }

    time+=1/frameRate;
  }
}
