xxxxxxxxxx
32
// Text Along Circle, Xin Xin, 2020
let sentence = "HELLOWORLD";
let sentenceArray = [];
let r = 100; // radius
let theta = 0;
function setup() {
createCanvas(400, 400);
textAlign(CENTER);
textSize(18);
fill(255);
sentenceArray = sentence.split(""); // splits a string into an array of chars
print(sentenceArray);
}
function draw() {
background(185, 20, 222);
translate(width / 2, height / 2);
for (let i = 0; i < sentenceArray.length; i++) {
rotate(QUARTER_PI/1.25); // rotation for the group of letters, which affects the spacing between letters
push();
translate(r * sin(theta), r * cos(theta));
rotate(PI); // rotation for individual letter
text(sentenceArray[i], 0, 0);
pop();
}
}