xxxxxxxxxx
52
let angle = 0;
let numRows = 4; // Number of rows
function setup() {
createCanvas(500, 500);
background(0);
}
// A function to draw the text once with noise
function drawTextWithNoise() {
textSize(20);
fill(255);
let txt = "perfect chaos"; // set the text
let letters = txt.split(""); // create a list of characters
let txtWidth = txt.length * textWidth("A"); // calculate the total width of the text
let spacing = (width - txtWidth) / (letters.length - 1); // calculate the spacing between letters
let rowHeight = (3 * height / 4) / numRows; // calculate the row height
for (let j = 0; j < numRows; j++) {
for (let i = 0; i < letters.length; i++) {
let x = width / 2 - txtWidth + i * spacing; // Center the text horizontally
let y = j * rowHeight + 80; // Calculate the y position for each row
let h = map(sin(angle + x * 0.01), -1, 1, 0, 100);
// Draw the shadow without noise
fill(0, 100); // Set a shadow color with some transparency
text(letters[i], x + 2, y + rowHeight / 2 - h / 2 + 2); // Draw the shadow without noise
// Add noise to the shadow's position
let xOffset = random(-5, 5); // Randomly adjust the x position
let yOffset = random(-5, 5); // Randomly adjust the y position
fill(0, 100); // Set a shadow color with some transparency
text(letters[i], x + xOffset, y + rowHeight / 2 - h / 2 + yOffset); // Draw the shadow with noise
fill(255); // Set the text color to white
text(letters[i], x, y + rowHeight / 2 - h / 2); // Display the text
}
}
angle += 0.1;
}
function draw() {
drawTextWithNoise();
}