xxxxxxxxxx
34
let free = true;
function setup() {
createCanvas(400, 400);
stroke(0);
strokeWeight(2);
noFill();
}
function draw() {
background(255);
rect(50, 50, 150, 150)
check();
}
function check() {
let posx = mouseX;
let posy = mouseY;
let w = 5; // check area of pix
let off = floor(w / 2);
free = true;
for (let i = 0; i < w; i++) {
for (let j = 0; j < w; j++) {
let x = posx - off + i; // adjust to middle of area
let y = posy - off + j;
let cx = get(x, y);
if (brightness(cx) < 50) free = false;
// console.log("mx "+posx+" my "+posy+" x "+x+" y "+y+ " free "+free);
}
}
console.log("mx " + posx + " my " + posy + " free " + free);
}