Skip to content

Instantly share code, notes, and snippets.

@ta1hia
Created June 18, 2025 21:34
Show Gist options
  • Save ta1hia/b56f0e56834f32b82ff6641dda521c0c to your computer and use it in GitHub Desktop.
Save ta1hia/b56f0e56834f32b82ff6641dda521c0c to your computer and use it in GitHub Desktop.
pixelate script
let buffer;
let pixelSize = 12;
let size = 400;
function setup() {
createCanvas(1000, 1000);
textFont('Times New Roman');
textSize(size);
noStroke();
buffer = createGraphics(width, height);
buffer.background(255);
buffer.textFont('Times New Roman');
buffer.textSize(size);
buffer.fill(0);
buffer.textAlign(CENTER, CENTER);
buffer.text('Pixel', width/2, height/2);
}
function draw() {
background(255);
for (let x=0; x < buffer.width; x += pixelSize) {
for (let y=0; y < buffer.height; y += pixelSize) {
let c = buffer.get(x, y);
console.log(typeof(c));
fill(c);
rect(x, y, pixelSize, pixelSize);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment