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.
IndexDiscussionExhibition › Text around Circle
Page Index Toggle Pages: 1
Text around Circle (Read 734 times)
Text around Circle
Aug 19th, 2007, 12:30pm
 
Modifying an example from <nthitz>
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action=display;num=1183838521

I made this variation (press mouse buttons to change mode):

//circletext4
//2007-aug-1
//alphachapmtl
//pierrecharland@hotmail.com

//<left mouse> to change mode
//<right mouse> to toggle background redraw

PFont font;  

String[] names = {
 "0000","1111","2222","3333","4444","5555","6666","7777","8888","9999"};
//  "alpha","beta","gamma","delta","epsilon","1","22","333","4444" };  

float delta = TWO_PI / names.length;  
int radius = names.length *10;  
int radius0 = radius;
int mode=3;
boolean toggle=true;

float i0=0.0;
int cint,sint;
float ci0,si0;
float ci,si;

void setup() {
 size(600,600);  
 smooth();  
 font = createFont("CourierNewPSMT", 10);
 textFont(font,14);
 //
 cint=int(random(15))-7;
 if (cint!=0)
   ci0=1.0/cint;
 else ci0=0;
 sint=int(random(15))-7;
 if (sint!=0)
   si0=1.0/sint;
 else si0=0;
 println("cint,sint = "+cint+","+sint);
 //
}//setup()

void draw() {
 ci=ci0*i0;
 si=si0*i0;
 
 if (toggle) background(0);
 text("mode "+mode, width/2-20,height-2);  

 //set radius
 radius=radius0+int(names.length*6*cos(i0*delta));

 //draw corner circles
 if (toggle) stroke(220,110,55,255);
 else stroke(220,110,55,20);
 if (toggle) fill(220,110,55,31);
 else noFill();
 ellipse(0,0,radius,radius);
 ellipse(0,height,radius,radius);
 ellipse(width,height,radius,radius);
 ellipse(width,0,radius,radius);
 //draw center circle
 stroke(220,110,55,63);
 if (toggle) fill(220,110,55,47);
 else fill(220,110,55,15);
 ellipse(width/2,height/2,radius,radius);

 for(int i = 0; i<names.length; i++) {
   pushMatrix();

   float xPos = width/2 + (radius*cos(i*delta+ci));  
   float yPos = height/2 + (radius*sin(i*delta+si));
   translate(xPos, yPos);

   //draw ring circles
   stroke(55,110,220,63);
   if (toggle) fill(55,110,220,20);
   else fill(55,110,220,5);
   ellipse(0,0,radius,radius);

   //draw text
   switch(mode) {
   case 0:
     rotate(i0*delta); //parallel text, in_sync pulsation
     break;
   case 1:
     rotate(i0); //parallel text, off_sync pulsation
     break;
   case 2:
     rotate((i0+i)*delta); //radial text, in_sync pulsation
     break;
   case 3:
     rotate(i0 + (i*delta)); //radial text, off_sync pulsation
     break;
   default:
     exit();
   }
   fill(255,255,255,255);
   text(names[i], 0, 0);  

   popMatrix();    
 }//for

 i0+=0.15;
}//draw()

void mousePressed() {
 if (mouseButton == LEFT) {
   mode=(mode+1)%4;
   println("mode = "+mode);
 }
 else if (mouseButton == RIGHT) {
   toggle=!toggle;
 }
}//mousePressed()

//void keyPressed() {
//  ...
//}//keyPressed()


Page Index Toggle Pages: 1