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 › text to image help
Page Index Toggle Pages: 1
text to image help (Read 1100 times)
text to image help
May 26th, 2009, 12:45am
 
Hi,

just trying to convert text to image, i searched before and found a function but its really really ugly. the text gets all distorted. any solutions for making it clearer? or why its doing what its doing?

Code:

PFont font;
PGraphics p;
int posy;
int count;

void setup(){
  size(600,600);
 
 font = loadFont("Serif-20.vlw");
 textFont(font);  

 p = createGraphics(300,500,P3D);

}

void draw(){
 background(0);
 createtext();
}

void createtext(){

 p.beginDraw();
 p.fill(255);
 p.textFont(font);
 p.text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam hendrerit nunc in metus dignissim at interdum nunc laoreet. Quisque feugiat urna quis nibh pellentesque pellentesque. Ut fringilla ipsum eu augue varius sollicitudin at nec mauris. Quisque convallis erat diam, at tincidunt eros. Pellentesque sem dolor, tempor at pellentesque non, dictum. ",0,0,300,500);
 p.endDraw();
 image(p,20,20);
}



cheers,
Re: text to image help
Reply #1 - May 26th, 2009, 2:08am
 
use JAVA2D instead of P3D for the Pgraphics and also draw a p.background(0);

Re: text to image help
Reply #2 - May 26th, 2009, 4:32am
 
Also you probably don't need to create the image on each draw() iteration (unless you plan to modify some parameter each time, of course).
Re: text to image help
Reply #3 - May 26th, 2009, 5:50am
 
thanks alot guys, knew it would be something simple.

looks alot better!
Page Index Toggle Pages: 1