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 › random fonts & color
Page Index Toggle Pages: 1
random fonts & color (Read 919 times)
random fonts & color
Sep 27th, 2009, 8:17am
 
Hi I started processing yesterday.

I'm frustrated. T.T
Please help me.

I want to make : When text typed, each character typed by each other font & color.

I don't Know what to do.
Please give me a hint or answer.

----------------------------------------------------------------------
PFont f1;
PFont f2;
int r;
int g;
int b;

String typing = "";


void setup() {
 size(800,600);
 f1 =createFont("BaseMonoWideBold",24,true);
 f2 =createFont("SansSerif",48,true);
   background(255,255,255);
 fill(0);
}

void draw() {
 int indent = 25;
// Set the font and fill for text
 
 // Display everything
 textFont(f1);
 text("type your message.",indent,90);
 textFont(f2);
 text(typing,indent,150);
}

void keyPressed() {
   typing = typing + key;
    r = int(random(255));
    g = int(random(255));
    b = int(random(255));
fill(r,g,b);
}

void mousePressed(){
   saveFrame("text-####.jpg");
}
--------------------------------------------------------



Do you understand this writing?

Sorry. My english skill is so bad. T.T
Re: random fonts & color
Reply #1 - Sep 27th, 2009, 9:30am
 
It's not that simple. Since you want to change the color for each character, you need to draw them separetly. You will need to deal with text() and textWidth() manually.
Re: random fonts & color
Reply #2 - Sep 28th, 2009, 2:30am
 
Page Index Toggle Pages: 1