let tempos = [{in:33, out:43}, {in:53, out:63}, {in:73, out:83}, {in:93, out:103}, {in:113, out:123}];
let cores = ['#B8FCC0', '#609669', '#FAACDA', '#F4D03F', '#FFBA76'];
let tempoDeTroca = 10000;
let contadorDeCores = new Array(cores.length).fill(0);
bodyPose = ml5.bodyPose();
musica = loadSound("PROJETO JULIA_1.mp3")
myCapture = createCapture(VIDEO);
myCapture.size(640, 480);
engine = Matter.Engine.create();
engine.world.gravity.y = 1;
let paredeEsquerda = Matter.Bodies.rectangle(0, height / 2, 20, height, { isStatic: true });
let paredeDireita = Matter.Bodies.rectangle(width, height / 2, 20, height, { isStatic: true });
let paredeSuperior = Matter.Bodies.rectangle(width / 2, 0, width, 20, { isStatic: true });
let paredeInferior = Matter.Bodies.rectangle(width / 2, height, width, 20, { isStatic: true });
Matter.World.add(world, [paredeEsquerda, paredeDireita, paredeSuperior, paredeInferior]);
bodyPose.detectStart(myCapture, gotPoses);
const tempo = musica.currentTime();
for(var i = 0; i < tempos.length; i++){
if(tempos[i].in < tempo && tempos[i].out > tempo) {
if(corAtual != undefined){
Matter.Engine.update(engine);
if (agora - ultimoTempo >= tempoDeTroca) {
console.log("Porcentagens de cores:");
for (let i = 0; i < cores.length; i++) {
let porcentagem = (contadorDeCores[i] / bolas.length) * 100 || 0;
console.log(`${cores[i]}: ${porcentagem.toFixed(2)}%`);
circle(width-mao1.x, mao1.y, 10);
circle(width-mao2.x, mao2.y, 10);
function gotPoses(results) {
function desenharBolas() {
for (let bola of bolas) {
fill(bola.render.fillStyle);
ellipse(bola.position.x, bola.position.y, bola.circleRadius * 2);
function drawVideoBackground() {
image(myCapture, 0, 0, width, height);
let lastHandPositions = [];
function drawHandPoints() {
for (let i = 0; i < poses.length; i++) {
if (lastHandPositions[i]) {
for (let j = 0; j < pose.keypoints.length; j++) {
let prevPosition = lastHandPositions[i][j] || { x: 0, y: 0 };
let distX = pose.keypoints[j].x - prevPosition.x;
let distY = pose.keypoints[j].y - prevPosition.y;
movement += Math.sqrt(distX * distX + distY * distY);
lastHandPositions[i] = pose.keypoints.map(p => ({ x: p.x, y: p.y }));
let numBalls = int(map(movement, 0, 300, 0, 5, true));
for (let j = 0; j < numBalls; j++) {
let hand = pose.keypoints[random([9, 10])];
mao1 = pose.keypoints[9];
mao2 = pose.keypoints[10];
let novaBola = Matter.Bodies.circle(
width - hand.x + random(-15, 15),
hand.y + random(-15, 15),
Matter.World.add(world, novaBola);
contadorDeCores[indice]++;
function exibirContadorDeCores() {
let titulos = ["Saúde", "Vida Financeira", "Vida Amorosa", "Trabalho", "Vida Social"];
for (let i = 0; i < cores.length; i++) {
text(`${titulos[i]}: ${contadorDeCores[i]}`, 10, yOffset);
function drawDiagnosticInfo() {
text("FPS: " + int(frameRate()), 40, 30);