xxxxxxxxxx
72
let myString = "hello !ssalc ";
function setup() {
createCanvas(600, 600);
textFont("Courier New", 25);
}
class Letter{
constructor(_c, _x, _y, radius, my_angle,len) {
this.x=_x;
this.y=_y;
this.char = _c;
this.rad = radius;
this.ang = my_angle;
this.length = len;
}
update() {
// this.x += this.xSpeed;
// this.y += this.ySpeed;
// this.xSpeed *= 0.01;
// this.ySpeed *= 0.01;
this.x = cos(this.ang) * this.rad;
this.y = sin(this.ang) * this.rad;
this.angle += TWO_PI/this.length;
}
display() {
text(this.char, this.x, this.y);
// circle(this.c, this.x, this.y);
}
run(){
this.update();
this.display();
}
}
function draw() {
background(255);
let angle = PI;
let radius = 100;
push();
translate(width/2, height/2);
for (let i=0; i<myString.length; i++){
let myChar = myString.charAt(i);
len = myString.length;
let x = cos(angle) * radius;
let y = sin(angle) * radius;
// text(myChar, x, y);
angle += TWO_PI/myString.length;
my_let = new Letter(myChar, x,y, radius, angle, len);
my_let.run();
}
pop();
}