xxxxxxxxxx
192
// proyecto consiste en salvapantallas con captura de video en vivo.Se ñaden imágenes a utilizar.
let webcam;
let kokoro;
let tr;
let glitter;
let confeti;
//Se crea fondo en tono negro y se añade video en vivo via webcam e imágenes como recurso estilo destello.
function setup() {
createCanvas(800, 600, WEBGL);
webcam = createCapture(VIDEO);
kokoro = loadImage("1010.png");
tr = loadImage("2020.png");
glitter = loadImage("3030.png");
confeti = loadImage("90901.gif");
webcam.hide();
}
//se dimensiona imagen de video
function draw() {
background(0, 0, 0);
webcam.size(150, 100);
/*se dimensionan imágenes en diferentes diseños y tamaños de manera aleatoria con figuras circulares para que parezcan pequeños flashes.
en proceso !!! se quiere bajar la velocidad en la que aparecen sin modificar la velocidad de rotaciñon de los cubos. */
//corazón con aparición aleatoria en lienzo
push();
translate(random(width), random(height));
fill(209, 0, 195);
noStroke();
image(kokoro, -400, -300, 20, 20);
pop();
push();
translate(random(width), random(height));
fill(209, 0, 195);
noStroke();
image(kokoro, -400, -300, 25, 25);
pop();
//figura con aparición aleatoria en lienzo
push();
translate(random(width), random(height));
fill(209, 0, 195);
noStroke();
image(tr, -400, -300, 20, 20);
pop();
//destello con aparición alleatoria en lienzo
push();
translate(random(width), random(height));
fill(255, 255, 255);
noStroke();
image(glitter, -400, -300, 40, 40);
pop();
//APARICIÓN DESTELLOS
//círculo grande amarillo con aparición aleatoria en lienzo
push();
translate(random(width), random(height));
fill(255, 255, 0);
noStroke();
circle(-450, -250, 2);
pop();
//círculo grande blanco con aparición aleatoria en lienzo
push();
translate(random(width), random(height));
fill(255, 255, 255);
noStroke();
circle(-450, -250, 2);
pop();
//círculo pequeño blanco con aparición aleatoria en lienzo
push();
translate(random(width), random(height));
fill(209, 0, 195);
noStroke();
circle(-450, -250, 5);
pop();
push();
translate(random(width), random(height));
fill(255, 255, 255);
noStroke();
circle(-450, -250, 4);
pop();
//círculo grande amarillo con aparición aleatoria en lienzo
push();
translate(random(width), random(height));
fill(255, 255, 0);
noStroke();
circle(-450, -250, 5);
pop();
//círculo grande blanco con aparición aleatoria en lienzo
push();
translate(random(width), random(height));
fill(255, 255, 255);
noStroke();
circle(-450, -250, 2);
pop();
//aparición de cubos con imagen en vivo, rotación variada
//cubo pequeño
rotateZ(frameCount * 0.01);
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.01);
texture(webcam);
noStroke();
box(60, 60, 60);
push();
translate(0, 300, 0);
rotateZ(frameCount * 0.03);
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.02);
texture(webcam);
noStroke();
box(60, 60, 60);
pop();
push();
translate(0, -300, 0);
rotateZ(frameCount * 0.01);
rotateX(frameCount * 0.03);
rotateY(frameCount * 0.03);
texture(webcam);
noStroke();
box(60, 60, 60);
pop();
push();
translate(300, 0, 0);
rotateZ(frameCount * 0.02);
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.03);
texture(webcam);
noStroke();
box(60, 60, 60);
pop();
push();
translate(-300, 0, 0);
rotateZ(frameCount * 0.03);
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.02);
texture(webcam);
noStroke();
box(60, 60, 60);
pop();
push();
translate(0, 0, 300);
rotateZ(frameCount * 0.01);
rotateX(frameCount * 0.02);
rotateY(frameCount * 0.03);
texture(webcam);
noStroke();
box(60, 60, 60);
pop();
push();
translate(0, 0, -300);
rotateZ(frameCount * 0.03);
rotateX(frameCount * 0.02);
rotateY(frameCount * 0.01);
texture(webcam);
noStroke();
box(60, 60, 60);
pop();
//cubo grande central
push();
translate(0, 0, 0);
rotateZ(frameCount * 0.02);
rotateX(frameCount * 0.03);
rotateY(frameCount * 0.01);
texture(webcam);
noStroke();
box(250, 250, 250);
pop();
}