const textToWrite = "Frutillar";
let centerX, centerY, fontSize, INNER_RADIUS, RADIUS_VARIATION;
Montecatini= loadFont("MontecatiniPro-AmpioBold.ttf");
s = loadSound("ton_-_larosa.mp3");
amplitude = new p5.Amplitude();
for(var i = 0; i < 255; ++i)
phi[i] = TWO_PI * i / 255;
createCanvas(windowWidth, windowHeight);
centerY = windowHeight/1.8;
let screenPct = min(height, width) / 1000;
fontSize = screenPct * 100;
INNER_RADIUS = screenPct * 200;
RADIUS_VARIATION = screenPct * 100;
textFont('MontecatiniPro-AmpioBold');
function pointForIndex(pct) {
const NOISE_SCALE = 1.95;
let angle = pct * TWO_PI;
let cosAngle = cos(angle);
let sinAngle = sin(angle);
let time = frameCount / 100+20/(level+100);
let noiseValue = noise(NOISE_SCALE * cosAngle + NOISE_SCALE, NOISE_SCALE * sinAngle + NOISE_SCALE, time);
let radius = INNER_RADIUS + RADIUS_VARIATION * noiseValue;
x: radius * cosAngle + centerX,
y: radius * sinAngle + centerY
waveform = analyzer.waveform();
level = amplitude.getLevel();
strokeWeight(2.1+waveform[i+20]);
for(var i = 0; i < 255; i+=6)
curveVertex(r[i] * cos(phi[i]) * cos(mu), r[i] * sin(phi[i])) * sin(mu);
for (let i = 0; i < SEGMENTS; i++) {
let p0 = pointForIndex(i/SEGMENTS);
let pct = atan2(mouseY - centerY, mouseX - centerX) / TWO_PI;
let pixToAngularPct = 1/((INNER_RADIUS+RADIUS_VARIATION/2)*TWO_PI);
for (var k = 0; k < textToWrite.length; k++) {
let charWidth = textWidth(textToWrite.charAt(k));
pct += charWidth/1.8 * pixToAngularPct;
let leftP = pointForIndex(pct-0.1);
let rightP = pointForIndex(pct+0.1);
let angle = atan2(leftP.y - rightP.y, leftP.x - rightP.x) + PI;
let p = pointForIndex(pct*(f));
text(textToWrite.charAt(k), p.x-charWidth/2, p.y);
pct += charWidth/2 * pixToAngularPct;