xxxxxxxxxx
49
let vid;
let vidScale = 8;
let slider;
let median;
let bgCol = 0;
let ptCol;
function setup() {
createCanvas(640, 480);
pixelDensity(1);
vid = createCapture(VIDEO);
vid.size(width / vidScale, height / vidScale);
vid.hide();
}
function draw() {
background(bgCol);
vid.loadPixels();
loadPixels();
for (x = 0; x < vid.width + vidScale; x++) {
for (y = y = 0; y < vid.height + vidScale; y++) {
let index = (vid.width - x + 1 + y * vid.width) * 4;
let red = vid.pixels[index];
let green = vid.pixels[index + 1];
let blue = vid.pixels[index + 2];
let brightness = (red + green + blue) / 3;
// defining colour for circles and background
ptCol = color(random(200), random(200), random(255));
// bgCol = color(random(255),random(255),random(255))
fill(ptCol);
noStroke();
radius = map(brightness, 0, 255, 0, vidScale);
let curve1 = map(brightness, 0, 255, 0, vidScale);
// let marble = map(brightness,0,255,radius*2,radius*3)
ellipse(x * vidScale, y * vidScale, radius, 40);
}
}
}