ashlee3dee_Processing/Dungeon/Dungeon.pde
boolean recording = false; // A boolean to track whether we are recording are not
float timeScale = 0.0005f; //global amount to scale millis() for all animations
float currentTime = 0;
String title = getClass().getSimpleName();
BSPTree dungeon;

void settings() {
  size(800, 800, P3D);
}

void setup() {
  frameRate(30); //all code should be frame-rate independent. hint: use millis()
  smooth(2); //enable highest level of anti-aliasing your system can handle
  ellipseMode(CENTER);
  rectMode(CENTER);
  imageMode(CENTER);
  blendMode(BLEND);
  colorMode(HSB);
  background(0, 0, 0);
  dungeon = new BSPTree(4, 2, width);
}

void draw() {
  tick(); //no touch
  background(0);
  //dungeon.reset();
  dungeon.display();
  tock(); //no touch
}

/**
================================
Mandatory Code
================================
**/
@Override
void keyPressed() {
  if (key == 'r' || key == 'R') {
    recording = !recording;
  }
  if (key == 'j' || key == 'J') {
    println(
      "################################RESET################################"
    );
    //dungeon.reset();
    //dungeon.split();
    //println(dungeon.info());
    //dungeon.split();
    //dungeon.draw();
    //saveFrame("/output/"+title+"_frame_####.png");
  }
}

void tick() {
  currentTime = millis() * timeScale;
}

void tock() {
  if (recording) {
    saveFrame("output/frame_####.png");
  }
  //ui();
}

void ui() {
  drawFPS(255);
}

void drawFPS(int textColor) {
  pushMatrix();
  noStroke();
  fill(0);
  rect(0, 0, 100, 40);
  fill(textColor);
  text(frameRate, 0, 15);
  popMatrix();
}

// linear interpolate two colors in HSB space
color lerpColorHSB(color c1, color c2, float amt) {
  amt = min(max(0.0, amt), 1.0);
  float h1 = hue(c1), s1 = saturation(c1), b1 = brightness(c1);
  float h2 = hue(c2), s2 = saturation(c2), b2 = brightness(c2);
  // figure out shortest direction around hue
  float z = g.colorModeZ;
  float dh12 = (h1 >= h2) ? h1 - h2 : z - h2 + h1;
  float dh21 = (h2 >= h1) ? h2 - h1 : z - h1 + h2;
  float h = (dh21 < dh12) ? h1 + dh21 * amt : h1 - dh12 * amt;
  if (h < 0.0) h += z; else if (h > z) h -= z;
  colorMode(HSB);
  return color(h, lerp(s1, s2, amt), lerp(b1, b2, amt));
}

class c{public c(){}}