xxxxxxxxxx
36
const myStr = 'hello world'
let angleoffset;
let myChar;
function setup() {
angleoffset = 90;
createCanvas(600, 600);
textFont("Courier New", 25);
angleMode(DEGREES);
}
function draw() {
background(220);
push()
textAlign(CENTER);
text(myStr, width/2, height*0.25);
pop()
for(let i=0; i < myStr.length; i++){
myChar = myStr.charAt(i);
let startX = width/2-textWidth(myStr)/2;
let finalX = startX + textWidth(myChar)*i;
let ynoise = (noise((i+frameCount)*0.01)-0.5)*40;
text(myChar, finalX, ynoise+height*0.5);
}
const centerX = width/2;
const centerY = height*0.75;
const radius = 60;
angleoffset+=1
let angle;
for(let i=0; i < myStr.length; i++){
angle = angleoffset+360/myStr.length * i;
let dx = cos(angle) * radius;
let dy = sin(angle) * radius;
text(myStr.charAt(i), centerX + dx, centerY + dy);
}
}