xxxxxxxxxx
37
let img;
let ascii = "";
let asciiSize = 1;
function preload() {
img = loadImage("BozakToken.png");
}
function setup() {
createCanvas(img.width*2, img.height*2);
}
function draw() {
background(220);
image(img, 0, 0);
img.loadPixels();
let w = 1; // width / img.width;
let h = 1; // height / img.height;
for (let i = 0; i < img.width; i += asciiSize) {
for (let j = 0; j < img.height; j += asciiSize) {
let index = (i + j * img.width) * 4;
let r = img.pixels[index];
let g = img.pixels[index + 1];
let b = img.pixels[index + 2];
let avg = (r+g+b)/3;
noStroke();
fill(avg);
//square(img.width+i, j, 1);
square(img.width+ i*w, j*h, w);
}
}
}