xxxxxxxxxx
40
let cols; let rows; let w = 5; let h;
let img; let c = [];
function preload(){
img = loadImage("images/face.png");
}
function setup() {
createCanvas(400, 450);
background(0);
h = w*2;
cols = width/w;
rows = height/h;
img.resize(400, 0);
strokeWeight(1);
for (let i=0; i<cols; i++) {
for (let j=0; j<rows; j++) {
// rect(i*w, j*h, w, h);
let co = img.get(i*w, j*h);
// if (co < 15) {
// stroke(color(219,170,186));
// } else if (co >= 15 && co < 33) {
// stroke(color(198,28,50));
// } else {
// stroke(color(50,77,182));
// }
stroke(co);
if (j % 2 == 0) {
line(i*w, j*h, i*w + w, j*h + h);
} else {
line(i*w + w, j*h, i*w, j*h + h);
}
}
}
}
function draw() {
// background(0);
}