xxxxxxxxxx
var img;
var a = 15
function preload() {
//img = loadImage("nasa_buzz.jpg");
}
function setup() {
createCanvas(640, 480);
img = createCapture(VIDEO);
img.size(640, 480);
img.hide();
//noLoop();
}
function draw() {
//image(img, 0, 0);
background(0);
img.loadPixels();
for (var y = 0; y < img.height; y += a) {
for (var x = 0; x < img.width; x += a) {
//var pix = red(img.get(x, y));
// Fast but complicated
var pix = img.pixels[(y * img.width + x) * 4];
if (pix <= 63) {
fill(100, 50);
noStroke();
ellipse(x, y, 20, 20);
} else {
if (pix <= 120) {
fill(150, 50);
ellipse(x, y, 20, 20);
} else {
if (pix <= 180) {
fill(200, 50);
ellipse(x, y, 20, 20);
} else {
fill(255, 50);
ellipse(x, y, 20, 20);
}
}
}
}
}
}