xxxxxxxxxx
const canvasMag = 0.4;
const emoji = ["🦄", "🧜♀️", "🎻", "🥞"];
const palette = ["#2c2d1d", "#5b5940", "#66664e", "#a6a48b", "#cfceaf"];
const bg = "#cfceaf";
function setup() {
createCanvas(2123 * canvasMag, 1461 * canvasMag);
pixelDensity(1 / canvasMag);
imageMode(CENTER);
noLoop();
}
function draw() {
background(bg);
let pg = createGraphics(width, height);
pg.background(255);
pg.textAlign(CENTER, CENTER);
pg.textSize(500);
pg.text(random(emoji), pg.width / 2, pg.height / 2);
// image(pg, pg.width/2, pg.height/2);
const squareSize = 10;
const numX = floor(width / squareSize);
const numY = floor(height / squareSize);
for (let i = 0; i < numX; i++) {
for (let j = 0; j < numY; j++) {
let c = pg.get(i * squareSize, j * squareSize);
let bri = brightness(color(c));
let index = floor(map(bri, 0, 100, 0, palette.length - 1));
// console.log(index);
fill(palette[index]);
noStroke();
square(i * squareSize, j * squareSize, squareSize);
}
}
}