NATURE OF CODE

A CERTAIN CHANCE

 

 

 

https://alpha.editor.p5js.org/full/Bk-RWGtVx

 

 

var mic;
var micLevel;
var points = [];
var x, y;
var px, py;

function setup() {

createCanvas(windowWidth, windowHeight);
textSize(25);
fill(0);
text(“SEGURO AZAR “, 0, 60);

mic = new p5.AudioIn()
mic.start();
x = width / 2;
y = height / 2;
px = x;
py = y;
noStroke();
//background(0);
}

function draw() {

//Move

x += random(-4, 4);
y += random(-4, 4);

// Draw a line from the previous loc to this loc
stroke(0, 0, 200);
line(px, py, x, y);

// Remember current location for next frame
px = x;
py = y;

micLevel = mic.getLevel();
console.log(micLevel);

//if(micLevel){
for (i = 0; i < points.length; i++) {
points[i].display(micLevel);
}

noStroke(10);
fill(247, 170);
}

function mouseMoved() {
if (mouseMoved) {
var newPoint = new Point();
newPoint.xpos = mouseX;
newPoint.ypos = mouseY;
newPoint.display(micLevel);
// newPoint.displayOffset(micLevel);
points.push(newPoint);
}
}

function Point() {
this.xpos = 0;
this.ypos = 0;
this.display = function(micLevel) {
//fill(255,0, 0);
ellipse(this.xpos, constrain(this.ypos – micLevel * this.ypos * 10, 0, this.ypos), 60, 10);
//fill(0,0,255);
ellipse(this.xpos, constrain(this.ypos – 40 + micLevel * this.ypos * 10, 0, this.ypos), 10, 10);
//point(this.xpos + micLevel ,this.ypos + micLevel);
}
// this.displayOffset = function(micLevel){
// ellipse(this.xpos, constrain(this.ypos+micLevel*this.ypos*5, 0, this.ypos), 1, 1);
textSize(30);
//fill(250);
text(“CERTAIN CHANCE “, 40, 100);
text(“CERTAIN CHANCE “, 80, 200);
text(“CERTAIN CHANCE “, 90, 300);
text(“CERTAIN CHANCE “, 100, 400);

}

Comment

Loading Facebook Comments ...

Leave a Reply

Your email address will not be published.