/**adWord(number).java by gregvan
 * RECOMMENDED SIZE: height 120, width 750
* you may change the words by modifying
* the html on your webpage... parameters
* pass what you want to say to the applet
*<applet code=aartword(number).class
*height=120 width=750>
*<param name="sw" value="Silly Words...">
*</applet>
**/


import java.applet.*;
import java.awt.*;

public class aartword14 extends Applet implements Runnable
{
   
int rr,gg,bb;//color variables  
int r1=1; //color up-down counters
int g1=1;  
int b1=1;   

int cx; // applet.width/4
int cy; // applet.height/4
int cx2;
int cy2;
int size=16;
int size1=1;


String stationaryWords;        
        Thread    myRunner;


        Image     buffer;         
        Dimension appletSize;     
        Graphics  bufferGraphics;
        
        public void init()
        {
// get the words from the webpages html                


stationaryWords=getParameter("sw");
if (stationaryWords==null){stationaryWords="";} 
            
      setBackground(Color.black);
               
      appletSize = this.getSize();

      buffer = this.createImage(appletSize.width, appletSize.height);
      cx=appletSize.width/4;
      cy=appletSize.height/4;
  cx2=appletSize.width/2;
cy2=appletSize.height/2;
      bufferGraphics = buffer.getGraphics();
        }

        public void start()
        {
                if (myRunner == null)
                { 
                      
                        myRunner = new Thread(this);
                        myRunner.start();
                }
        }

        public void run()
        {
             
                Thread  executingThread;
                                
                executingThread = Thread.currentThread();

                while (myRunner == executingThread)
                {
                  //new random numbers to start animation
	rr=(int)(Math.random() *256);
	gg=(int)(Math.random() *256);
	bb=(int)(Math.random() *256);
	 

                        repaint();
                        try
                        {
              // sleep for 1 second (1000 msec = 1 sec)
                                Thread.sleep(100);
                        }
                        catch(InterruptedException e) 
                        {
                        } 

                        while (myRunner != null)
                        {
                               
                                repaint(); 
                                try
                                {
                     // pause for .1 second
                               Thread.sleep(100);  
                                }
                                catch (InterruptedException e) 
                                {
                                }
                        }  
                }  //end while thread executing
        }

        //suspends execution when user leaves page
        public void stop()
        { 
                if (myRunner != null)
                {
                        myRunner = null;
                }
        }

        public void update(Graphics g)
        {
                paint(g);
        }


        public void paint(Graphics g)
        {


size=size+size1;
if(size>cy+cy2){size1=-1;}
if(size<15){size1=1;}

//color changer 
        rr=rr+21;
        if(rr>255){rr=rr-255;}
       
        gg=gg+8;
        if(gg>255){gg=gg-255;}
        
        bb=bb+13;
        if(bb>255){bb=bb-255;}
       


Color eNew = new Color(rr, gg, bb);
   bufferGraphics.setColor(eNew);
   bufferGraphics.setFont(new Font("Serif",Font.PLAIN,size));

//use the parameters sent from the webpage

bufferGraphics.drawString(""+stationaryWords,10,cy+cy2); 
              
        g.drawImage(buffer, 0, 0, this);
        }
}//end of program

