Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1678
| From | "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> |
|---|---|
| Subject | "fading" graphics using G |
| Message-ID | <46552116$0$4719$4c368faf@roadrunner.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| Date | 2011-04-27 15:34 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui Hello everyone, I started a small Java program just as something fun to do. It simulates a sonar, like on a submarine. Right now I'm at the point where I have multiple objects moving independently around the sonar screen with a rotating needle. I keep track of the speed/location/etc. of each object which extends Thread. The needle rotates around the screen in a way that lights up the part it just touched and the glow gradually fades away using a gradient that I created. The objects on the screen only change location when the needle intersects them (using the intersects() method of java.awt.geom.Line2D.Double). The problem is that at this point the objects "jump" to the new location because their last displayed location is still on the display. I believe a real sonar works in such a way that all the objects that are detected gradually fade away and just before totally disappearing the needle lights them up again in their newest location. I'm having trouble figuring out a way to get the object icon (just an oval right now drawn using fillOval()) and its label (drawn using drawString()) to gradually fade away. The first problem I ran into was that the object stayed drawn on the sonar screen even when it had actually moved out of "range" of the sonar. Later I realized that if it faded away like it is supposed to I wouldn't have to worry about drawing over top of the old location when it moved out of range because it would go away on its own and come back when it was back in range on the sonar. Currently I'm saving the old location but painting the icon and text again using a transparent color obviously doesn't erase the painted object and text from its last location. I also can't actually paint over the existing icon/text with background colors because it is over top of the gradient from the needle glow fading away and I wouldn't be able to come up with the perfect pattern to paint over it to match the gradient at that location at a particular point in time. I tried to paint all objects and labels before the sonar needle was painted with its gradient but in order to still see them through the gradient requires transparency on the gradient and that slows down the rendering tremendously, too much for it to be worth it. I have the gradient stretch the entire 360 degrees of the circle so there is no point on the sonar where there isn't a gradient. (It goes from yellow to green). I've attempted to get the icon/text to fade away like I do the needle glow by setting up a loop and gradually increasing the transparency level but that doesn't seem to work even with just 1 object. I have a feeling I wouldn't be able to get it to work with multiple objects whose fade has to be independent anyway because the sonar needle would go over them at different times. I'm running out of ideas on how to get this to work so I'm just fishing around for ideas at this point. I tried to explain my program and my problem the best I could especially for those not familiar with a sonar device but if needed I can probably post the whole program this time (unlike my other posts about my other program) since the full program is just under 500 lines. Then anyone who wants to can test it to see what I'm talking about. thanks for any ideas. Brandon --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Next in thread | Find similar | Unroll thread
"fading" graphics using G "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
Re: "fading" graphics usi "visionset" <visionset@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
Re: "fading" graphics usi "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
csiph-web