jeonghopark
4/14/2016 - 3:43 PM

pixelsCircleHole_06_musicMultiTone.pde

import processing.sound.*;

PImage img;

SinOsc sine;
SinOsc secondSine;
float freq=400;
float freqSecond=400;

void setup() {

  size(600, 300);
  
  sine = new SinOsc(this);
  sine.play();
  
  secondSine = new SinOsc(this);
  secondSine.play();
  
  img = loadImage("parrot.jpg");

  colorMode(HSB);
  rectMode(CENTER);

  noStroke();
  
}


void draw() {

  background(120);

  image(img, 0, 0);

  int _color = 0;
  _color = img.get(mouseX, mouseY);
  fill(_color);
  rect(mouseX, mouseY, 50, 50);



  pushMatrix();
  translate(360, 60);
  for (int j=0; j<180; j++) {
    for (int i=0; i<180; i++) {
      fill(hue(_color), map(i, 0, 180, 0, 255), map(j, 0, 180, 255, 0));
      rect(i, j, 1, 1);
    }
  }

  pushStyle();
  translate(map(saturation(_color), 0, 255, 0, 180), map(brightness(_color), 255, 0, 0, 180));
  fill(_color);
  stroke(255);
  rect(0, 0, 10, 10);
  popStyle();

  popMatrix();


  freq=map(hue(_color), 0, 255, 100, 800);
  sine.freq(freq);

  freqSecond=map(saturation(_color), 0, 255, 100, 800);
  secondSine.freq(freqSecond);

  printlInformation(_color);
}


void printlInformation(color _color) {
  println( red(_color), " + ", green(_color), " + ", blue(_color) );
  println( hue(_color), " + ", saturation(_color), " + ", brightness(_color) );
}