xxxxxxxxxx
87
var sound;
var fft;
var textToDisplay = ' ✩₊˚.⋆☾⋆⁺₊✧"';
var text2 = " ✩₊˚.⋆☾⋆⁺₊✧";
var isPaused = false;
let poemLines = [];
let img;
function preload() {
sound = loadSound('show2.m4a');
poemLines = loadStrings('shigeru.txt');
//img = loadImage('assets/night 1.png');
}
function setup() {
createCanvas(600, 600);
fft = new p5.FFT();
sound.amp(0.8);
delay = new p5.Delay();
delay.process(sound, 0.8, 0.5, 2300);
sound.play();
setInterval(togglePause, 3000); // every 3 seconds pause
}
function draw() {
if (!isPaused) {
background('red');
//image(img, -80, -100);
// waveform text
var wave = fft.waveform();
textSize(10);
fill('255');
let poemText = poemLines.join(''); // Join array into a single string
let chars = split(poemText, ''); // Split the string into an array of characters
for (var i = 0; i < 200; i++) {
var index = floor(map(i, 0, width, 0, wave.length));
var x = i;
var y = wave[index] * 300 + 300;
if (i < chars.length) {
shearX(PI / 100);
text(chars[i], 10*x, y);
text(chars[i], 5*x, y-180);
}
}
// circling text
let radius = 300;
let angleStep = HALF_PI / textToDisplay.length;
let animate = frameCount / 300;
translate(width/2, height/2);
for (let i = 0; i < textToDisplay.length; i++) {
let angle = i * animate;
let x = radius * cos(angle);
let y = radius * sin(angle);
push();
translate(x, y);
rotate(280 + HALF_PI);
textSize(8);
text(textToDisplay.charAt(i), 100, 0);
//fill('yellow');
//text(text2.charAt(i), 0-50, 0+50);
pop();
}
}
}
function togglePause() {
isPaused = !isPaused;
if (isPaused) {
sound.pause();
noLoop();
} else {
sound.play();
loop();
}
}