xxxxxxxxxx
78
let vid
let vidScale = 5;
let slider;
// let breaks[51,102,153,204]
let input;
function setup() {
createCanvas(640, 480);
pixelDensity(1);
vid = createCapture(VIDEO);
vid.size(width / vidScale, height / vidScale);
vid.hide();
slider = createSlider(0,255,0)
}
function draw() {
background(slider.value());
vid.loadPixels();
loadPixels();
for (x = 0; x < vid.width + vidScale / 2; x+=2) {
for (y = y = 0; y < vid.height + vidScale / 2; y+=2) {
let index = (vid.width-x+1 + (y * vid.width)) * 4;
let red = vid.pixels[index];
let green = vid.pixels[index + 1];
let blue = vid.pixels[index + 2];
let brightness = (red + green + blue) / 3;
console.log(255/vidScale)
noStroke()
radius = map(brightness, 0, 255, 0, vidScale);
fill(brightness)
// square(x * vidScale, y * vidScale, radius);
textSize(8)
textAlign(CENTER)
// blendMode(MULTIPLY)
let mark = 255/vidScale
if(brightness<mark/2){
input='🖤'
} else if(brightness>mark/2&&brightness<mark){
input='🤎'
}else if(brightness>mark&&brightness<mark*2){
input='❤️'
}
else if(brightness>mark*2&&brightness<mark*3){
input='🧡'
}
else if(brightness>mark*3&&brightness<mark*4){
input='💛'
}else {
input='🤍'
}
text(input,x*vidScale,y*vidScale)
// pixels[index] = red;
// pixels[index + 1] = green;
// pixels[index + 2] = blue;
// pixels[index + 3] = 255;
}
}
// updatePixels();
}