xxxxxxxxxx
64
let vid;
let button;
let gallery = [];
let w = 60;
let h = 40;
let x = 0;
let y = 0;
let total =100
readyBool = false;
function setup() {
createCanvas(600, 400);
background(220);
vid = createCapture(VIDEO,ready);
vid.size(600, 400);
vid.hide();
// frameRate(40);
// button = createButton("capture image");
// button.mousePressed(click);
}
function ready() {
readyBool = true;
}
function draw() {
// image(vid, 0, 0);
let counter = 0;
if (readyBool) {
gallery[counter]=vid.get();
counter++
if (counter==total){
counter=0
}
}
let g = map(y,height,0,0,255)
let b = map(x,0,height,0,255)
tint(0, g, b);
for (i = 0; i < gallery.length; i++) {
image(gallery[(i+frameCount)%gallery.length], x, y, w, h);
x = x + w;
if (x > width) {
x = 0;
y = y + h;
}
if (y > height) {
y = 0;
}
}
}
function click() {
// gallery.push(vid.get());
// console.log(gallery)
// image(vid,0,0)
}