Current File : /home/jeshor13/11bsouth.com/HonkBoard0.1/graphics.js
function basicSign() {
  fill("white")
  strokeWeight(width * 0.01)
  rect(width * 0.01, height * 0.01, width * 0.98, height * 0.98)
  fill("black")
  noStroke()
  textFont(highwayFont);
  textSize(ceil(sqrt(height * width)) / 10); // set largest font based on canvas area
  text(headlineText, ((width * 0.50) - (textWidth(headlineText) * 0.50)), height * 0.15)
  textSize(ceil(sqrt(height * width)) / 12);
  text(midlineText, ((width * 0.50) - (textWidth(midlineText) * 0.50)), height * 0.285)
  textSize(ceil(sqrt(height * width)) / 15)
  text(bottomlineText, ((width * 0.50) - (textWidth(bottomlineText) * 0.50)), height * 0.83)
    //stroke("yellow")
    //strokeWeight(2)
  if (honkCount0 == honkCount) {
    noStroke()
    rect(width * 0.025, height * 0.325, width * 0.95, height * 0.425)
  }
  if (honkCount0 != honkCount) {
    stroke(255, 204, 0)
    strokeWeight(5)
    rect(width * 0.025, height * 0.325, width * 0.95, height * 0.425)
    stroke(0, 0, 0)
    strokeWeight(0)
  }
  rect(width * 0.025, height * 0.85, width * 0.95, height * 0.12)
  honkCount0 = honkCount
  textSize(height * 0.11)
  fill("green")
  textAlign(RIGHT);
  text(int(honkCount / 22), width * 0.03, height * 0.95, width * .95)
    // Sets the image on the main display depending on variable
  if (honkCount <= 300) {
    image(lightSmile, (width * 0.25), height * 0.325, (width * 0.50), (height * 0.45));
  }
  if (honkCount > 300 && honkCount < 800) {
    image(flatMouth, (width * 0.25), height * 0.325, (width * 0.50), (height * 0.45));
  }
  if (honkCount >= 800) {
    image(sadEyesAndTear, (width * 0.25), height * 0.325, (width * 0.50), (height * 0.45));
  }
  ///
  for (k = 0; k < p_spectrumMax.length; k++) {
    if (p_spectrumMax[k] == 0) {
      p_spectrumMax[k] = spectrum[k]
    }
    if (p_spectrumMax[k] <= spectrum[k]) {
      p_spectrumMax[k] = spectrum[k]
    }
  }
  var leastSq = 0
  for (ii = 0; ii < honkSoundLevels.length; ii++) {
    leastSq = (leastSq + abs((honkSoundLevels[ii] - spectrum[ii])) ^ 2)
  }
  if (leastSq / honkSoundLevels.length <= 14) {
    honkCount++
  }
  ///
}

function consoleData() {
  noFill();
  background(200);
  for (k = 0; k < p_spectrumMax.length; k++) {
    if (p_spectrumMax[k] == 0) {
      p_spectrumMax[k] = spectrum[k]
    }
    if (p_spectrumMax[k] <= spectrum[k]) {
      p_spectrumMax[k] = spectrum[k]
    }
  }
  stroke("green")
  beginShape();
  for (j = 0; j < p_spectrumMax.length; j++) {
    vertex(j, map(p_spectrumMax[j], 0, 255, height, 0));
  }
  endShape();

  beginShape();
  stroke('black')
  for (i = 0; i < spectrum.length; i++) {
    vertex(i, map(spectrum[i], 0, 255, height, 0));
  }
  endShape();

  var leastSq = 0
  for (ii = 0; ii < honkSoundLevels.length; ii++) {
    leastSq = leastSq + abs((honkSoundLevels[ii] - spectrum[ii]) ^ 2)
  }
  if (leastSq / honkSoundLevels.length <= 14) {
    honkCount++
  }
  text("LeastSQ:" + ceil(leastSq / honkSoundLevels.length), 20, 20)
  text("Honk like sounds: " + honkCount, 20, 40)
}