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 › basic animation question
Page Index Toggle Pages: 1
basic animation question (Read 629 times)
basic animation question
Apr 24th, 2008, 6:13pm
 
hi guys,

sorry for this beginner question, but i just can't find nowhere pretty clear, how it works with animation etc.

for example, I create a pretty complex graphic with 100 rects and lines.
Now i want to fade out only one rect of them all. do i have to clear (background(0)Wink draw the complex graphic every frame new and only pass this one rect i want to fade out every frame - 1 until its alpha is 0 ?
that seems to be very performance costly?

for example, how did he do this: http://transition.turbulence.org/Works/mypocket/graph/pop.html
does he have to draw everything new every frame?


Thanks a lot!
Re: basic animation question
Reply #1 - Apr 26th, 2008, 12:43am
 
yes you have to clear the background every frame, otherwise you'll get "ghosting" it's really not costing you anything because graphics are redrawn every frame anyways.  if you want to animate the alpha you need to have some sort of counter in your code:

int a=10;

draw{
 fill(10,10,10,a);
 draw stuff...
 a-=1;
}

that way each iteration decrease the alpha by 1.

Re: basic animation question
Reply #2 - Apr 28th, 2008, 4:28pm
 
That's an interesting matter actually!
In your case I think the best thing is just draw the hole thing every frame because 100 rects are not that mutch anyway.

  but.....

If there was a way of clearing only one area of the screen then we could make an application that draws a quarter of a screen at a time for example and be able to build really complex graphic animations really fast!

Is this a crazy idea?? is there a way to clear only one area of the screen??

One other thing would be the capability to save part or the hole of the screen buffer allready drawn and save it in memory to save the program from having to recalculate everything all over again. I mean... for example if we have a game with the same background most of the time then we could just draw the background once and save it and just draw the animation part. (like display lists in OpenGL)

 just some ideas to discuss, greets everyone!!
Page Index Toggle Pages: 1