Hello there
At the end of this work, which interacts with sound and visual, I want to add one more thing: darkening the background color with mouse movement as I pinch the sound effect.
How can I do that?
PImage img;
import processing.sound.*;
Sound s;
void setup() {
size(600,600, P3D);
img = loadImage("eye02.jpg");
img.resize(600,600);
SinOsc sin = new SinOsc(this);
sin.play(150, 0.2);
sin = new SinOsc(this);
sin.play(205, 0.2);
s = new Sound(this);
}
void draw() {
float amplitude = map(mouseY, 0, height, 0.4, 0.0);
s.volume(amplitude);
background(#e6e6e6);
float s = mouseX / float(width);
specular(s, s, s);
noStroke();
fill(#000000);
ellipse(mouseX, mouseY,10,10);
sphereDetail(2);
float tiles = mouseX;
float tileSize = width/tiles;
push();
translate(width/2, height/2);
rotateY(radians(frameCount));
for (int x = 0; x < tiles; x++){
for (int y = 0; y < tiles; y++){
color c = img.get(int(x*tileSize),int(y*tileSize));
float b = map(brightness(c),0,255,1,0);
float z = map(b,0,0,-100,100);
push();
translate(x*tileSize - width/2, y*tileSize - height/2);
sphere(tileSize*b*0.8);
pop();
}
}
pop();
}