xxxxxxxxxx
let capture;
function setup() {
capture = createCapture(VIDEO);
capture.size(480, 320);
createCanvas(capture.width, capture.height);
capture.hide();
noStroke();
}
function draw() {
if (!capture) {
//do nothing if the webcam capture isn't ready yet.
return;
}
//get the current video image into an image for quicker access
let img = capture.get(0, 0, capture.width, capture.height);
//prepare the image to be queried about its pixels
img.loadPixels();
const gridSize = 15;
for (let x = 0; x < width; x += gridSize) {
for (let y = 0; y < height; y += gridSize) {
let z = mouseX;
const diameter = noise(0.002 * x, 0.002 * y, 0.01 * z)* gridSize * 1.4;
const pixelColour = img.get(x, y);
fill(pixelColour);
square(x, y, diameter);
}
}
}
function mousePressed() {
// if (random([true, false])) {
// image(capture, 0, 0)
// } else {
background(255);
// }
}