Poster

posted in Yar
Published October 18, 2005
Advertisement
You might have seen my thread in the Lounge, but in case you didn't here is a poster that I made for my Orchestra concert coming up here in November...


Click to bring up a bigger version.

I started working on my text display class... does anybody know how to make text fade in and out? this seems like such a chore to figure out by myself (remember I'm a java monkey). Anyway, more updates later.
Previous Entry Sound Manager, again...
Next Entry Text Boxes!
0 likes 2 comments

Comments

stormrunner
Well, as of yet I haven't tried this (it's on my to-do list), but the most logical way (imho) would be to use a transparency composite and update the alpha value (increase or decrease depending on which operation you're doing; fade in or out) as a function of time. Example transparency source; composite function taken from here.


// relevant includes go here ...

public class DrawTransparentText {
   // the composite generation function
   // this simply tells Java2d how transparent
   // the render of the subsequent drawing calls
   // should be
   private AlphaComposite makeComposite(float alpha) {
       int type = AlphaComposite.SRC_OVER;
       return(AlphaComposite.getInstance(type, alpha));
   }
   // random "timer" variable
   private float   m_fade = 3.0f;   

   public void drawText(Graphics2D g2d, String text, /* other stuff ... */) {
       // again, you need to save the old composite value
       // because you have to reset it, otherwise
       // all drawing operations to this graphics context
       // will be transparent (which is bad ..)
       Composite saved = g2d.getComposite();
       // just an example ...
       g2d.setComposite(makeComposite(m_fade * 0.1f);
       // set up the color, font, ect
       // the color is now transparent 
       // (with the selected alpha value)
       g2d.setColor( ... );
       // draw the string
       g2d.drawString( ... );
       // reset the composite
       g2d.setComposite(saved);
   }
}



Hope that was somewhat useful.
October 18, 2005 11:20 PM
H_o_p_s
I forgot that you could set the alpha through the Graphics2D object… thanks!
October 19, 2005 01:03 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

!!!!!!!

671 views

MIDI Keyboard v1.7

1534 views

Yar.

1204 views

Orchestra Recording

1318 views

MIDI Keyboard v1.5

1452 views

Registration

1317 views

Ahhh!!!

1084 views

Um... yeah...

1071 views
Advertisement