here is a 'drawText()' method you can reuse :
Code:void drawText(String s, float x, float y, float radius, float angle, boolean invert)
- 's' is the string to write,
- 'x' 'y' and 'radius' define the center + radius of the circle the text will be written around
- 'angle' is the position of the text around the circle
- 'invert' indicates whether the text has to be inverted or not (when angle is between PI/2 and 3*PI/2, you may want to use invert, so it's not written upside down)
Example :
Code:void drawText(String s, float x, float y, float radius, float angle, boolean invert) {
pushMatrix();
if (invert) {
textAlign(RIGHT, CENTER);
translate(x, y);
rotate(angle);
translate (radius, 0);
pushMatrix(); rotate(PI); text(s, 0, 0); popMatrix();
} else {
textAlign(LEFT, CENTER);
translate(x, y);
rotate(angle);
translate(radius, 0);
text(s, 0, 0);
}
popMatrix();
}
void setup() {
size(200, 200);
PFont font = loadFont("ArialNarrow-12.vlw");
textFont(font, 12);
smooth();
noLoop();
}
void draw() {
background(255);
noFill();
ellipse(width/2, height/2, 40*2-5, 40*2-5);
fill(0);
int n = 12;
for (int i = 0; i < n; i++) {
float a = i*TWO_PI/n;
if (a >= PI/2 && a < 3*PI/2)
drawText("inside ->", width/2, height/2, 40, a, true);
else
drawText("outside ->", width/2, height/2, 40, a, false);
}
}