|tropo://techno/java/starry, starry night/secrets|
|Starry, Starry Night Secrets|
The Starry, Starry Night Applet is done with two classes, though in theory in could be crammed into one.
The base class TRBufferedApplet (src/javadoc) is a type of Applet that takes care of drawing into an offscreen image so as to avoid flickering.
The derived class
) does all the real work of
parsing parameters, starting up an animation thread,
tracking the mouse, and drawing the stars.
describes the parameters at the top.
The key drawing method is
and it draws stars of a given size via a hardcoded switch statement.
One other hi tech thing done here is that we make sure that
paint() is not called too often as otherwise that hoses the animation.
TBD the frame rate applet will demonstrate this. See the
and track the calls to them to see what I mean.
Make sure you see the article on animation and also tip 8 and tip 9 in Javaworld for issues with Applets resizing under Netscape.