import java.applet.Applet; import java.awt.*; public class top extends Applet implements Runnable { Image off; Image back; Image star; Graphics off_g; Thread th; MediaTracker mt; String s; char c[] = new char[30]; top_char t_char[] = new top_char[30]; double ra; int fast_draw[] = new int[30]; int count_f; int last_draw[] = new int[30]; int count_l; /*********init()***********/ public void init(){ off = createImage(300,300); off_g = off.getGraphics(); th = null; mt = new MediaTracker(this); s = "Welcome to My Homepage!"; s.getChars(0,s.length(),c,0); for (int i = 0; i < s.length(); i++) t_char[i] = new top_char(c[i]); star = getImage(getCodeBase(),"star.gif"); mt.addImage(star,0); back = getImage(getCodeBase(),"back.gif"); mt.addImage(back,0); ra = Math.PI*2; count_f = 0; count_l = 0; } /*********start()**********/ public void start(){ if (th == null){ th = new Thread(this); th.start(); } } public void stop(){ if (th != null){ th.stop(); th = null; } } /********update()**********/ public void update(Graphics g){ paint(g); } /********run()***********/ public void run(){ while (true){ if (mt.checkID(0)){ repaint(); } else { try { mt.waitForID(0); }catch(InterruptedException e){} } /********sleep*********/ try{ th.sleep(120); } catch (InterruptedException e){} } } /*********paint()*********/ public void paint(Graphics g){ if (mt.isErrorID(0)){ off_g.setColor(Color.black); off_g.fillRect(0,0,getSize().width,getSize().height); off_g.setColor(Color.white); off_g.drawString("Load Error...",50,50); } else if (mt.checkID(0)){ off_g.drawImage(back,0,0,this); off_g.setFont(new Font("Dialog",Font.PLAIN,20)); for (int i = 0; i < s.length(); i++){ double ra2 = ra + ((Math.PI/16)*i); t_char[i].setXY(ra2); if (Math.sin(ra2) >= 0) fast_draw[count_f++] = i; else last_draw[count_l++] = i; } for (int i = 0; i < count_f; i++) t_char[fast_draw[i]].draw(off_g); off_g.drawImage(star,(getSize().width/2)-75, (getSize().height/2)-75,this); for (int i = 0; i < count_l; i++) t_char[last_draw[i]].draw(off_g); if (ra < Math.PI/16) ra = Math.PI*2; else ra -= Math.PI/16; count_f = 0; count_l = 0; } else { off_g.setColor(Color.black); off_g.fillRect(0,0,getSize().width,getSize().height); off_g.setColor(Color.white); off_g.drawString("Now Loding...",50,50); } g.drawImage(off,0,0,this); } }