We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › ALIGN TEXT ON PATH
Page Index Toggle Pages: 1
ALIGN TEXT ON PATH (Read 1001 times)
ALIGN TEXT ON PATH
Jan 23rd, 2006, 12:44pm
 
Hello.

I have a problem with a project of us.
For that we need to align text to a path (text should align to a circle path).

...and I dont know how to do this.

Can somebody help us?
We would be really thankful for an answer giving us a clue doin it...

Re: ALIGN TEXT ON PATH
Reply #1 - Jan 23rd, 2006, 1:40pm
 
Code:

size(300,300);
textFont(loadFont("ArialMT-48.vlw"),20);//load a font and set textfont
String s="eskimoblood"; //the string
int l=s.length(); //the length of the string
int r=100; //the radius of the circle
//now for every char of the string calculate the position on a circle
for(int i=0;i<l;i++){
float x=sin(-TWO_PI/l*i+PI)*r;
float y=cos(-TWO_PI/l*i+PI)*r;
pushMatrix();
translate(x+width/2,y+height/2);
rotate(TWO_PI/l*i);
char c=s.charAt(i);
text(c,0,0);
popMatrix();
}
Re: ALIGN TEXT ON PATH
Reply #2 - Jan 23rd, 2006, 1:58pm
 
THANGX a LOT !!!

U MADE MY DAY!!!
Re: ALIGN TEXT ON PATH
Reply #3 - Jan 23rd, 2006, 2:36pm
 
I'm currently doing a library which should make this very simple.  But this is only the theory, in practice, I have to do a restructuration of the interface, so things will change  and become incompatible in later releases.

here's a bit of code:

Code:

import geomerative.*;

RShape path;
RGroup texto;
RFont font;
float t=0;

String string="Whatever text you want to adapt to the circle goes here.";

void setup(){
size(800,600,P3D);
framerate(50);
font = new RFont(this,"YourTrueTypeFont.ttf",372,RFont.CENTER);
texto = font.toGroup(string);

path = new RShape();
path = path.createCircle(200);
}

void draw(){
background(255);
fill(0);
translate(width/2,height/2);
noStroke();

RGroup.setAdaptorLengthOffset(t);
RGroup.setAdaptorScale(0.1);
RGroup newTexto = texto.adaptTo(path);

newTexto.draw(g);

t+=0.001;
t%=1;
}


for this to work you need to install the library  Geomerative

and you'll need to copy a True Type font in the data directory of your sketch.

hope it helps!
Page Index Toggle Pages: 1