• Advertisement
Sign in to follow this  
  • entries
    208
  • comments
    383
  • views
    65732

Poster

Sign in to follow this  

307 views

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.
Sign in to follow this  


2 Comments


Recommended Comments

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.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement