xxxxxxxxxx
76
let echoesLines = [];
let dots = [];
let dotSize = 20;
let currentIndex = 0;
let revealSpeed = 2; // Adjust the speed of dot reveal
let revealCharacter = true;
function preload() {
echoesLines = loadStrings('asa.txt');
}
function setup() {
createCanvas(600, 600, SVG);
textSize(16);
frameRate(20);
generateDots();
}
function generateDots() {
let y = 120;
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;
dots.push({ x: midX, y: y, revealed: false, character: character });
x += characterWidth;
}
y += 18;
}
}
function draw() {
background('rgb(240,251,255)');
for (let i = 0; i < dots.length; i++) {
let dot = dots[i];
fill(0);
text(echoesLines[i], 145, 125+i*18);
if (i <= currentIndex) {
fill('rgb(240,251,255)');
ellipse(dot.x, dot.y, dotSize, dotSize); // Draw a dot on top of the character
fill('rgb(240,251,255)');
//noStroke()
ellipse(random(150,460), dot.y, dotSize, dotSize);
}
push();
textSize(14);
textAlign(CENTER);
text('量子詩第1596番', width/2, 540);
pop();
}
currentIndex += revealSpeed;
if (currentIndex >= dots.length) {
noLoop(); // Stop the animation when all dots are revealed
}
}
function mousePressed(){
save("mySVG.svg"); // give file name
print("saved svg")
}