xxxxxxxxxx
let capture;
function setup() {
createCanvas(640, 480);
capture = createCapture(VIDEO);
capture.hide();
capture.size(640, 480);
}
function draw() {
background(0);
noStroke();
fill(177);
if (capture.width > 0) {
let img = capture.get(0, 0, capture.width, capture.height);
img.loadPixels();
const step = 50;
for (var y = step; y < img.height; y += step) {
for (var x = step; x < img.width; x += step) {
var i = y * img.width + (img.width-x-1);
const darkness = ((0,0,255) - img.pixels[i * 4]) / (0,0,255);
let sX = x * width / img.width;
let sY = y * height / img.height;
if (darkness > 0.80) {
fill('#1919a6');
square(sX, sY, step);
}else
if (darkness > 0.5) {
fill('#faed27');
square(sX, sY, step);
}
}
}
}
}
stroke(0)
strokeWeight(20)
// noStroke()
let c = get(mouseX, mouseY)
textSize(24)
text(c, 50, 50)
fill(0, 255, 0)
let blue = color( 25, 25, 166)
if (c[0] === 0 && c[1] === 0 && c[2] === 0) {
fill(255, 0, 0)
console.log('true')
circle (mouseX, mouseY, 10, 10)
}