xxxxxxxxxx
53
let diameter = 50;
let mic;
let x;
let y;
let maxSpeed = 5;
function setup() {
createCanvas(400, 400);
noStroke();
background(50);
colorMode(HSB);
mic = new p5.AudioIn();
mic.start();
x = width / 2;
y = height / 2;
}
function draw() {
//background(128);
if(mouseIsPressed){
stroke(255, 255, 255, 30);
}else{
noStroke();
}
// Now in HSB, 0-360 for hue, 0-100 for saturation and luminance
let hue = map(x, 0, width, 0, 360);
fill(hue, 100, 100, 0.5);
diameter = mic.getLevel() * 200;
x += random(-maxSpeed, maxSpeed);
y += random(-maxSpeed, maxSpeed);
circle(x, y, diameter);
}
function keyPressed(){
if(key == ' '){
background(50);
}
}