Look Deep Into My Eyes

While frantically trying to come up with an idea for my ICM midterm, I had this image of a ring of eyes spinning around stuck in my head. Maybe it was all of those hours of work on my Comm Lab Web final and the PComp media controller project that sent me into a delirium, or maybe it was Alessandra Villaamil’s Hypnotoad glasses, but this trippy vision would not go away. So I decided to build it as my midterm. If you hold down any key, the eyes change color and shift around space as though floating on a stream.

This is the code for the main sketch:

[code lang="java"]EyeWheel eyewheel1;
EyeWheel eyewheel2;
EyeWheel eyewheel3;
EyeWheel eyewheel4;
 
void setup ()
{
  size(650, 650);
  eyewheel1 = new EyeWheel(0, 0, 200, 159, 255, 52);
  eyewheel2 = new EyeWheel(0, 0, 275, 255, 24, 3);
  eyewheel3 = new EyeWheel(0, 0, 125, 38, 86, 252);
  eyewheel4 = new EyeWheel(0, 0, 325, 78, 17, 247);
}
 
void draw()
{
  background(0);
  stroke(255);
  strokeWeight(1.5);
  randomSeed(20);
  for(int i=0; i<600; i++)
  {
    point(random(width), random(height));
  }
   
  smooth();
  noStroke();
  eyewheel1.rotateEyeWheel();
  eyewheel1.drawEyeWheel();
  eyewheel1.invEyeWheel();
   
  translate(-width/2, -height/2);
  eyewheel2.rotateEyeWheel();
  eyewheel2.drawEyeWheel();
  eyewheel2.invEyeWheel();
   
  translate(-width/2, -height/2);
  eyewheel3.rotateEyeWheel();
  eyewheel3.drawEyeWheel();
  eyewheel3.invEyeWheel();
   
  translate(-width/2, -height/2);
  eyewheel4.rotateEyeWheel();
  eyewheel4.drawEyeWheel();
  eyewheel4.invEyeWheel();
}
 
void eyefxn(float x, float y, int R, int G, int B)
{
   fill(R, G, B);
   ellipse(x, y, 100, 75);
   fill(255, 181, 44, 172);
   ellipse(x, y, 100, 75);
   fill(R, G, B, 155);
   ellipse(x, y, 75, 75);
   fill(0, 0, 0, 240);
   ellipse(x, y, 20, 55);
}[/code]

This is the code for the Eyewheel class:

[code lang="java"]class EyeWheel
{
  float x, y;
  float d;
  int R, G, B;
  float angle = 0;
   
  EyeWheel(float _x, float _y, float _d, int _R, int _G, int _B)
  {
    x = _x;
    y = _y;
    d = _d;
    R = _R;
    G = _G;
    B = _B;
  }
   
  void drawEyeWheel()
  {
    fill(255, 255, 255, 0);
    ellipse(x, y, d, d);
     
    eyefxn(x, y-d, R, G, B);
    eyefxn(x, y+d, R, G, B);
    eyefxn(x+d, y, R, G, B);
    eyefxn(x-d, y, R, G, B);
  }
   
  void rotateEyeWheel()
  {
    angle += .008;
    translate(width/2, height/2);
    rotate(angle);
  }
   
  void invEyeWheel()
  {
    if(keyPressed == true)
    {
      filter(INVERT);
      translate(-width/4, -height/4);
      eyefxn(width/2, height/2, 255, 255, 255);
    }
  }
}[/code]