xxxxxxxxxx
57
let cols, rows;
let spacing = 20;
const density = "Ñ@#W$9876543210?!abc;:+=-,._ ";
function setup() {
createCanvas(800, 800);
cols = width / spacing;
rows = height / spacing;
textFont('monospace');
textSize(12);
noStroke();
}
function draw() {
background(0);
noiseDetail(8, 0.4);
for (let i = 0; i < cols; i++) {
for (let j = 0; j < rows; j++) {
let x = i * spacing;
let y = j * spacing;
// Calculate distance to mouse
let d = dist(mouseX, mouseY, x, y);
let maxDist = 100; // Maximum influence range
// Deflection effect
let deflectX = 0;
let deflectY = 0;
if (d < maxDist) {
let angle = atan2(y - mouseY, x - mouseX);
let force = map(d, 0, maxDist, 30, 0); // Stronger push when closer
deflectX = cos(angle) * force;
deflectY = sin(angle) * force;
}
// Apply deflection
let newX = x + deflectX;
let newY = y + deflectY;
// Using Perlin noise for smoother character selection
let noiseVal = noise(i * 0.1, j * 0.1, frameCount * 0.02) * density.length;
let charIndex = floor(noiseVal);
let char = density.charAt(charIndex);
// Generate color based on Perlin noise
let r = noise(i * 0.05, j * 0.05, frameCount * 0.05) * 255;
let g = noise(i * 0.07, j * 0.07, frameCount * 0.05) * 255;
let b = noise(i * 0.09, j * 0.09, frameCount * 0.05) * 255;
fill(r, g, b);
text(char, newX, newY);
}
}
}