xxxxxxxxxx
57
let echoesLines = [];
let points = []; // Store the points for dots
let dotSize = 10;
let currentIndex = 0; // Index to keep track of the characters to convert
function preload() {
echoesLines = loadStrings('asa.txt');
}
function setup() {
createCanvas(600, 600);
textSize(16);
generatePoints();
frameRate(10); // Adjust the frame rate for animation speed
}
function generatePoints() {
let y = 125;
for (let i = 0; i < echoesLines.length; i++) {
let line = echoesLines[i];
let x = 145;
for (let j = 0; j < line.length; j++) {
let character = line.charAt(j);
let characterWidth = textWidth(character);
let midX = x + characterWidth / 2;
points.push({ x: midX, y: y, revealed: false, character: character });
x += characterWidth;
}
y += 18;
}
}
function draw() {
background(220);
// Display the text
for (let i = 0; i < currentIndex; i++) {
let point = points[i];
text(point.character, point.x, point.y);
}
// Gradually reveal the points in an animation
for (let i = 0; i < currentIndex; i++) {
let point = points[i];
if (!point.revealed) {
ellipse(point.x, point.y, dotSize, dotSize); // Draw a dot at each point
point.revealed = true;
}
}
currentIndex++;
if (currentIndex >= points.length) {
noLoop(); // Stop the animation when all points are revealed
}
}