• entries
208
383
• views
66064

# Poster

342 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.

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

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 ...
// 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.

I forgot that you could set the alpha through the Graphics2D object… thanks!

## Create an account

Register a new account