xxxxxxxxxx
85
var windmillsp = 0;
var mic;
let textObjs = [];
let speed = 0;
let gravite = 0.1;
let movex = 5;
let sunfaces = 0;
function preload() {
wbody = loadImage('windmillbody.png');
img = loadImage('7.png');
vid = createCapture(VIDEO);
}
function setup() {
createCanvas(400, 400);
vid.hide();
angleMode(DEGREES);
mic = new p5.AudioIn();
mic.start();
}
function draw() {
background(220);
drawimag();
image(wbody, 75, 150, 250, 250);
var vol = mic.getLevel();
windmill();
textgenerate();
if(vol>0.1){
textpush();
}
}
function windmill(){
var vol = mic.getLevel();
push();
fill(0)
noStroke();
translate(200, 210);
rotate(windmillsp);
rectMode(CENTER);
rect(0,0,100,10);
rect(0,0,10,100);
windmillsp= windmillsp+100*vol
pop();
}
function textpush() {
textObjs.push({ttxt:RiTa.randomWord(),xpos: 150, ypos: 200,fillColor:random(0,150),size:random(10,20),xmove:random(-5,5)});
}
function textgenerate(){
for (let i = 0; i < textObjs.length; i++) {
fill(textObjs[i].fillColor);
textSize(textObjs[i].size);
text(textObjs[i].ttxt,textObjs[i].xpos, textObjs[i].ypos);
textObjs[i].ypos = textObjs[i].ypos + speed;
speed = gravite + speed;
textObjs[i].xpos = textObjs[i].xpos+textObjs[i].xmove;
}
for (let i = textObjs.length - 1; i >= 0; i--) {
if(speed>0){
speed = 0;
}
if (textObjs[i].ypos > height || textObjs[i].xpos > width) { textObjs.splice(i, 1);
}
}
}
function drawimag(){
push();
translate(50,50);
imageMode(CENTER);
rotate(sunfaces);
sunfaces = sunfaces+0.5;
img.mask(img);
image(vid,0,0,100,100)
image(img,0,0,300,300)
pop();
}