xxxxxxxxxx
var img;
var emoji_bright, emoji_brightest, emoji_middle, emoji_dark, emoji_darkest;
function preload() {
emoji_brightest = loadImage("DBD 4");
emoji_bright = loadImage("DBD 2");
emoji_middle = loadImage("DBD 1");
emoji_dark = loadImage("DBD 3");
emoji_darkest = loadImage("DBD 5 .png");
}
function setup() {
createCanvas(1440, 980);
img = createCapture(VIDEO);
img.size(1440, 980);
img.hide();
}
function draw() {
//image(img, 0, 0);
background(0);
img.loadPixels();
for (var y=0; y<img.height; y+=20)
{
for (var x=0; x<img.width; x+=20)
{
//var pix = red(img.get(x, y));
// Fast but complicated
var pix = img.pixels[(y*img.width+x)*4];
if (pix <= 30)
image(emoji_darkest, x, y, 20, 20);
else if (pix > 30 && pix < 80)
image(emoji_dark, x, y, 20, 20);
else if (pix > 80 && pix < 130)
image(emoji_middle, x, y, 20, 20);
else if (pix > 130 && pix < 200)
image(emoji_bright, x, y, 20, 20);
else if (pix > 200)
image(emoji_brightest, x, y, 15, 15);
}
}
}