xxxxxxxxxx
var img;
var emoji_brightest, emoji_bright, emoji_middle, emoji_dark;
function preload() {
//img = loadImage("nasa_buzz.jpg");
emoji_brightest = loadImage("flower_light.PNG");
emoji_bright = loadImage("flower_middle1.PNG")
emoji_middle = loadImage("flower_middle2.PNG")
emoji_dark = loadImage("flower_dark.PNG");
}
function setup() {
createCanvas(1440, 980);
img = createCapture(VIDEO);
img.size(1440, 980);
img.hide();
//noLoop();
}
function draw() {
//image(img, 0, 0);
background(255);
img.loadPixels();
for (var y=0; y<img.height; y+=10)
{
for (var x=0; x<img.width; x+=10)
{
//var pix = red(img.get(x, y));
// Fast but complicated
var pix = img.pixels[(y*img.width+x)*4];
if (pix <= 64) {
image(emoji_dark, x, y, 10, 10);
} else if (pix > 64 && pix < 128) {
image(emoji_middle, x, y, 10, 10);
} else if (pix >= 128 && pix < 196) {
image(emoji_bright, x, y, 10, 10);
} else if (pix >= 196) {
image(emoji_brightest, x, y, 10, 10);
}
}
}
}