xxxxxxxxxx
var img;
var emoji_bright, emoji_dark, emoji_lightgrey, emoji_darkgrey;
var a = 20
function preload() {
//img = loadImage("nasa_buzz.jpg");
emoji_bright = loadImage("zebra.png");
emoji_dark = loadImage("buffalo.png");
emoji_lightgrey = loadImage("dolphin.png");
emoji_darkgrey = loadImage("elephant.png");
}
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) {
image(emoji_dark, x, y, a, a);
} else {
if (pix <= 120) {
image(emoji_darkgrey, x, y, a, a);
} else {
if (pix <= 180) {
image(emoji_lightgrey, x, y, a, a);
} else {
image(emoji_bright, x, y, a, a);
}
}
}
}
}
}