xxxxxxxxxx
102
var osc;
var playing = false;
function setup() {
createCanvas(400, 400);
actualPainting()
osc0 = new p5.Oscillator();
osc1 = new p5.Oscillator();
osc2 = new p5.Oscillator();
osc3 = new p5.Oscillator();
osc0Params()
osc1Params()
osc2Params()
osc3Params()
}
function osc0Params() {
osc0.setType('sine');
osc0.freq(120+(random(2)));
osc0.amp(0);
osc0.start();
}
function osc1Params(){
osc1.setType('sine');
osc1.freq(240+(random(1)));
osc1.amp(0);
osc1.start();
}
function osc2Params(){
osc2.setType('sine');
osc2.freq(720);
osc2.amp(0);
osc2.start();
}
function osc3Params(){
osc3.setType('sine');
osc3.freq(1200+(random(4)));
osc3.amp(0);
osc3.start();
}
function draw() {
}
function mouseClicked() {
oscPlayState()
}
function oscPlayState(){
if (mouseX > 0 && mouseX < width && mouseY < height && mouseY > 0) {
if (!playing) {
// ramp amplitude to 0.5 over 0.05 seconds
osc0.amp(0.5, 2);
osc1.amp(0.4, 3);
osc2.amp(0.3, 5);
osc3.amp(0.2, 8);
playing = true;
} else {
// ramp amplitude to 0 over 0.5 seconds
osc0.amp(0, 8);
osc1.amp(0, 13);
osc2.amp(0, 21);
osc3.amp(0, 34);
playing = false;
}
}
}
function actualPainting(){
background(146,27,33);
for(x=0;x<=400;x+=4){
// for(y=0;y<=400;y+=4){
strokeWeight (1)
stroke (3,7,10)
fill (238, 212, 153)
bezier(x, height, 0, x/2, 100, 0, 400, 0, 0, 0, 100, 0);
// line (x, height, 100/x, 0);
// }
}
stroke (3,7,10)
fill (59, 55, 99)
for (y=400; y>=0; y-=3){
bezier(400, y, 0, 200, 100, 0, 400, 0, 0, 0, 100, 0);
}
}