xxxxxxxxxx
61
// let pic;
let video;
// // function preload() {
// // pic = loadImage("dog.png");
// // }
// function preload() {
// video = createCapture(VIDEO);
// }
function setup() {
createCanvas(400, 400);
// pic.resize(50,50);
video = createCapture(VIDEO);
video.size(50,50);
}
function draw() {
background(0);
let r, g, b, bright;
//image(pic,0,0, width, height );
video.loadPixels();
let w = width/video.width;
let h = height/video.height;
let chr = "swostik";
//console.log(chr.length);
k = 0;
for(let i = 0; i<video.width; i++){
for(let j=0; j< video.height; j++){
pixelI = (j + i* video.width) *4;
r = video.pixels[pixelI +0];
g = video.pixels[pixelI +1];
b = video.pixels[pixelI +2];
bright = (r+g+b)/3;
noStroke();
fill(bright);
//square(i*w, j*h, w);
textSize(w);
textAlign("CENTER", "CENTER");
//text(chr[k], i*w + w*0.5, j*h +h*0.5);
text(chr[k], j*h +h*0.5, i*w + w*0.5);
if(k <= chr.length-2) {
k++;
}
else {
k = 0;
}
}
}
}