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 & HelpPrograms › drawing text without looping
Page Index Toggle Pages: 1
drawing text without looping (Read 588 times)
drawing text without looping
Nov 10th, 2005, 7:18am
 
Is there a way to do a one time loop in Processing to display text without screwing up the main draw loop?

I have a good amount of text I want to display from a for loop, and since the background is being redrawn, it only displays in the draw loop.

This seems like a huge waste of processor time, since it is redrawing the lines over and over.

I'm just using it as an aesthetic background.
Its 50 lines of sourcecode with almost no line spacing.

So any suggestions?

Thanks  Smiley
Re: drawing text without looping
Reply #1 - Nov 10th, 2005, 10:52am
 
I think theres no other way of redrawing it in case you have a changing background.
Re: drawing text without looping
Reply #2 - Nov 10th, 2005, 11:19am
 
I'm not sure I fully understand what you mean.

Are you using the for loop to write text out to the screen, but don't want to do this every frame? Where you could write it once and copy it to a PImage that could then be used as a background(title); or something like that?

Sorry if I'm misunderstanding you.
Re: drawing text without looping
Reply #3 - Nov 10th, 2005, 7:37pm
 
Ya basically I have a block of text that is being parsed from a text file.
I want it to draw the text, but since I'm not animating it I would like it not to redraw.

This works if I put the text() in the setup, but then since there IS motion in the draw loop, I have to redraw the background color there..or it looks funky.

Just looking for a way I guess to have a for loop in the draw loop that only runs the one time, emulating it being in the setup()
Re: drawing text without looping
Reply #4 - Nov 10th, 2005, 9:55pm
 

Sounds like you can do everything in the setup() i.e parse the file and write it to the screen and then just make a copy of it to another PImage called myBackground.

You can then just have a background(myBackground); in the draw() method, which will set the background to whatever was written there in the setup() and as you have motion in the loop anyway, my guess is that your clearing it in some way.

I seem to remember something weird happening with background(image) type stuff, so if it doesn't work just do a pixels[i] = mybackground.pixels[i] loop to copy it in.
Page Index Toggle Pages: 1