xxxxxxxxxx
66
let customFont;
let originalText = "نادوس";
let blurText;
function preload() {
customFont = loadFont('Handjet.ttf');
}
function setup() {
createCanvas(600, 600);
textFont(customFont);
textSize(25);
textAlign(CENTER, CENTER);
}
function draw() {
background(255);
let cols = 1;
let rows = 5;
let xOffset = width / 2 - (cols * textWidth(originalText)) / 4;
let yOffset = height / 2 - (rows * 50) / 3;
// Replace nested while loop with for loop
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
// Limit the number of text renderings
for (let k = 0; k < 5; k++) { // Reduced from 20 to 5
let modifiedText = replaceRandomCharacterWithSpace(originalText);
let verticalOffset = random(-100, 100);
// Randomize text properties
textSize(random(10, 40));
fill(0, 250);
// Draw text
text(modifiedText, xOffset + 20, yOffset + i * 50 + verticalOffset);
}
}
}
// Blurred text rendering remains the same
blurText = createGraphics(600, 600);
blurText.clear();
blurText.fill('red');
blurText.textSize(100);
blurText.textFont(customFont);
blurText.textAlign(CENTER, CENTER);
blurText.text("1956", blurText.width / 2, blurText.height / 2);
blurText.filter(BLUR, 1.2);
image(blurText, 0, 0);
function replaceRandomCharacterWithSpace(inputText) {
if (inputText.length === 0) return inputText;
let indexToReplace = floor(random(inputText.length));
return inputText.slice(0, indexToReplace) + " " + inputText.slice(indexToReplace + 1);
}
}
function keyPressed() {
if (key === 's') {
saveGif('mySketch', 2, { delay: 1 });
}
}