xxxxxxxxxx
94
let img;
let copy = `abcdefghijklmnopqrstuvwxyz`
let n = 0
let value = 1
let color = 'white'
function setup() {
createCanvas(windowWidth, windowHeight);
colorMode(HSB, 255)
capture = createCapture({
audio: false,
video: {
facingMode: {
exact: "environment"
}
}
});
capture.hide();
frameRate(10)
// Only run the draw function once, otherwise
// the program might work too hard redrawing things!
//noLoop()
}
function draw() {
background(0);
if (capture.loadedmetadata) {
//image(capture, 0, 0);
let temp_img = capture.get();
// translate(width,0);
// scale(-1, 1);
temp_img.resize(windowWidth, windowHeight)
let pixelSize = 15;
// 2. For each point in the grid...
for (let x = 0; x < windowWidth; x += pixelSize) {
for (let y = 0; y < windowHeight; y += pixelSize) {
// Get the brightness value for the image at (x, y)
let scalebright = brightness(temp_img.get(x, y))
let c = temp_img.get(x , y );
//console.log(c);
//fill(c)
fill(color)
pixelSize =11+ value ;
// pixelSize = 10 + scalebright/10;
// textSize(10)
textSize(value -3+ scalebright/10 )
//translate(width,0);
//scale(-1, 1);
text(copy[n], x, y)
n = (n + 1) % copy.length
noStroke()
noFill()
// rotate(radians(frameCount));
rect( x, y, pixelSize, pixelSize)
}
}
}
}
function mouseClicked() {
if (value === 1) {
value = 10;
} else {
value = 1;
}
}
function keyPressed() {
if (keyCode === LEFT_ARROW) {
color = 'red';
copy ='x'
} else if (keyCode === RIGHT_ARROW) {
color = 'green';
copy ='$'
}
else {
color = 'white';
copy ='&'
}
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}