xxxxxxxxxx
var img;
var emoji_brightest, emoji_bright, emoji_middle, emoji_dark;
function preload() {
//img = loadImage("nasa_buzz.jpg");
emoji_brightest = loadImage("heart_white.png");
emoji_bright = loadImage("heart_grey.png")
emoji_middle = loadImage("heart_grey1.png")
emoji_dark = loadImage("heart_black.png");
}
function setup() {
createCanvas(1440, 980);
img = createCapture(VIDEO);
img.size(1440, 980);
img.hide();
//noLoop();
}
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 <= 64) {
image(emoji_dark, x, y, 20, 20);
} else if (pix > 64 && pix < 128) {
image(emoji_middle, x, y, 20, 20);
} else if (pix >= 128 && pix < 196) {
image(emoji_bright, x, y, 20, 20);
} else if (pix >= 196) {
image(emoji_brightest, x, y, 20, 20);
}
}
}
}
function keyPressed() {
if (key == "s") {
save('tool_grafik.png');
}}