|
Author |
Topic: background / nobackground (Read 522 times) |
|
aalmos
|
background / nobackground
« on: Aug 3rd, 2003, 8:31am » |
|
I'm trying to write a program where some of the graphic elements gets refreshed from frame to frame and other graphics elements gets accumulated on the screen without being refreshed. Is there any simple way to do it in proce55ing? Thanks, a
|
|
|
|
benelek
|
Re: background / nobackground
« Reply #1 on: Aug 6th, 2003, 4:41am » |
|
argh, simple did you say? depending on the order of what you're drawing, you can keep an array of color values that would act as a "backup" of the background, which you would copy to after you make your "permanent" changes. for example: Code: color[] backup; void setup() { size(bla,bla); noBackground(); backup = new color[pixels.length]; System.arraycopy(pixels,0,backup,0,pixels.length); } void loop() { System.arraycopy(backup,0,pixels,0,pixels.length); //reset background as per the contents of the backup array. rect(bla,bla,bla,bla);//draw something to go onto the "permanent" background. System.arraycopy(pixels,0,backup,0,pixels.length);//add what you've just drawn to the "permanent" background. rect(moo,moo,moo,moo);//this will be removed at the begining of the next loop, thereby making it "temporary". } |
| is there a simpler, and infinitely more built-in way to do this? maybe!
|
|
|
|
fry
|
Re: background / nobackground
« Reply #2 on: Aug 6th, 2003, 5:56pm » |
|
actually that's the current method to do it. if someone can figure out a better syntax for it, maybe we can implement that. the better way will probably be to create a new BGraphics, draw to that, then draw that BGraphics into the main buffer by treating it as an image. we're working on making that simpler, so that'll probably be the recommended method.
|
|
|
|
fry
|
Re: background / nobackground
« Reply #3 on: Aug 6th, 2003, 5:56pm » |
|
oh, and the example benelek showed may have trouble with the zbuffer.. so if you're storing 3D objects you'll also need to copy g.zbuffer, which is an array of floats the same way you copy 'pixels'. ugh.
|
|
|
|
aalmos
|
Re: background / nobackground
« Reply #4 on: Aug 7th, 2003, 10:22am » |
|
I'm not that familiar with proce55ing but it seems to me that you need another level of abstraction here: You can have the main 'canvas' which can be static or refreshed and then you can create additional instances of 'canvas' and add them to the main 'canvas' or on top of each other. Each 'canvas' can have x,y,z, and static/refreshed properties. Any chance something like that will be implemented? Thanks, a
|
|
|
|
pitaru
|
Re: background / nobackground
« Reply #5 on: Aug 7th, 2003, 8:26pm » |
|
Re. a new level of abstraction - I think that the BSpace project (http://pitaru.com/processing/BSpace) is a beginning in that direction. I'll try to implement Background/noBackground into the next revision. -amit
|
« Last Edit: Aug 7th, 2003, 8:26pm by pitaru » |
|
|
|
|
|