Hey all,
I'm trying to write a program that will take an array of strings, and position the strings around a circle on the sketch. However I would like the text to be rotated so the names are coming out of the circle.
With rotate() it is easy to rotate text, but then when the text is placed on screen it does not go where I want it to within the circle.
The first for loop in this sketch is just an example of where the names are supposed to be placed. The second for loop includes rotates the text properly, but everything is placed incorrectly.
Can anyone help me out?
Quote:PFont font;
font = loadFont("dialoginput-10.vlw");
textFont(font,10);
size(400,400);
smooth();
background(0);
fill(255);
String[] names = {"nick","ben","justin","wes","dan","andy","matti","jess","pauL"};
float delta = TWO_PI / names.length;
int radius = names.length *10;
for(int i = 0; i<names.length; i++) {
text(names[i],width/2+radius * cos(i* delta), height/2+radius * sin(i*delta));
}
for(int i = 0; i<names.length; i++) {
rotate(i* delta);
float xPos = width/2+radius * cos(i* delta);
float yPos = height/2+radius * sin(i* delta);
text(names[i],xPos , yPos );
println(names[i] + " " +screenX(xPos,yPos) + " " + screenY(xPos,yPos) + " " + xPos+ " " +yPos+ " " +(i*delta/TWO_PI * 360) );
rotate(- i * delta); //reset rotation
}