/**fakewmd(number).java by gregvan 
 * RECOMMENDED SIZE: height 500, width 740
 **/

import java.applet.*;
import java.awt.*;

public class fakewmd30 extends Applet implements Runnable
{


int billy;
int billy1=-1;
int bob;
int bob1=1;
int pepper=4;
int pepper1=1;
int sgt;
int popper=2;
int popper1=-1;
int poopper=-3;
int poopper1=-1;
int fool=1;
int moon=3;
int gail=2;
int frank=1;
int zappa=2;

int fred;
int dweezel=1;
int john;
int paul;
int george;
int ringo;



int rr,gg,bb;//color variables 
int bw;//black and white 
int bwq=1;      
int rq=1; // color up-down factors
int gq=1;
int bq=1;

int cx; //center of screen x
int cy; //center of screen y

        Thread    myRunner;
        Image     buffer;         
        Dimension appletSize;     
        Graphics  bufferGraphics; 

        public void init()
        {    
        setBackground(Color.black);
        appletSize = this.getSize();     
        buffer = this.createImage(appletSize.width, appletSize.height);
        bufferGraphics = buffer.getGraphics();
	cx=appletSize.width/2;
        cy=appletSize.height/2;

        }

        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
	 

//random starting colors
rr=(int)(Math.random() *255);
gg=(int)(Math.random() *255);
bb=(int)(Math.random() *255);
bw=(int)(Math.random() *255);
john=-rr;
george=-gg;
paul=bb;
ringo=bw;
bob=rr+gg;
billy=bb+rr;


               repaint();
               try
               {Thread.sleep(1000);}
               catch(InterruptedException e) {} 

               while (myRunner != null)
               {
                  repaint(); 
                  try
                  {Thread.sleep(100); }
                  catch (InterruptedException e) {}
               }  
           } 
        }

       // make sure the animation really stops when exiting webpage
        public void stop()
        { 
          if (myRunner != null)
             { myRunner = null; }
        }

        //used to prevent blinking graphics....
        public void update(Graphics g)
        {paint(g);}

        public void paint(Graphics g)
        {

sgt=sgt+1;
if(sgt>160)
{sgt=1;
pepper=pepper+pepper1;
if(pepper>5){pepper1=-1;}
if(pepper<-5){pepper1=1;}
 
popper=popper+popper1;
if(popper>6){popper1=-1;}
if(popper<-6){popper1=1;}

poopper=poopper+poopper1;
if(poopper>4){poopper1=-1;}
if(poopper<-4){poopper1=1;}
 
}
   for (int ii=0;ii<3;ii++)
{//double ii loop

frank=frank+1;
if(frank>4){frank=1;}

     rr=rr+rq;
           if(rr>248){rq=-zappa;}
           if(rr<13){rq=zappa;}


        //for loop to paint many images before sleeping .1 second     
       for (int i=0;i<2;i++)
        {





zappa=zappa+1;
if(zappa>5){zappa=1;}

             //color changer up-down counters
          
if(rr>bb){fred=1;}
else{fred=6;}

       bw=bw+bwq;
           if(bw>248){bwq=-fred;}
           if(bw<8){bwq=fred;}
  
       gg=gg+gq;
           if(gg>249){gq=-zappa;}
           if(gg<14){gq=zappa;}
       bb=bb+bq;
           if(bb>250){bq=-zappa;}
           if(bb<15){bq=zappa;}


john=john+gail;
if(john>cx+320){gail=-frank;}
if(john<-(cx+220)){gail=zappa;}

paul=paul+dweezel;
if(paul>cx+280){dweezel=-zappa;}
if(paul<-(cx+380)){dweezel=frank;}

george=george+moon;
if(george>cx+250){moon=-zappa;}
if(george<-(cx+350)){moon=frank;}

ringo=ringo+fool;
if(ringo>cx+360){fool=-frank;}
if(ringo<-(cx+260)){fool=zappa;}

billy=billy+billy1;
if(billy>cx+210){billy1=-frank;}
if(billy<-(cx+310)){billy1=zappa;}

bob=bob+bob1;
if(bob>cx+300){bob1=-zappa;}
if(bob<-(cx+200)){bob1=frank;}





//////////////////////////////////////////////////////
 for (int i3=0;i3<7;i3++)
        {

if(i3==0)
{
//apply the new numbers for lines
        Color t0New = new Color(rr,gg, bb);
        bufferGraphics.setColor(t0New); 
}
if(i3==1)
{
//apply the new numbers for lines
        Color t1New = new Color(gg,256-rr, bb);
        bufferGraphics.setColor(t1New); 
}
if(i3==2)
{
//apply the new numbers for lines
        Color t2New = new Color(gg,256-bw, bb);
        bufferGraphics.setColor(t2New); 
}
if(i3==3)
{
//apply the new numbers for lines
        Color t3New = new Color(gg,rr, 256-bb);
        bufferGraphics.setColor(t3New); 
}
if(i3==4)
{
//apply the new numbers for lines
        Color t4New = new Color(0,0,0);
        bufferGraphics.setColor(t4New); 
}
if(i3==5)
{
//apply the new numbers for lines
        Color t5New = new Color(256-gg,bw, bb);
        bufferGraphics.setColor(t5New); 
}
if(i3==6)
{
//apply the new numbers for lines
        Color t6New = new Color(bw,bw,bw);
        bufferGraphics.setColor(t6New); 
}
paul=paul+(i3*popper);
george=george+(i3*pepper);
ringo=ringo-(i3*pepper);
john=john-(i3*popper);
billy=billy+(i3*poopper);
bob=bob-(i3*pepper);


bufferGraphics.drawLine(cx+john,cy+paul,cx+george,cy+ringo);
bufferGraphics.drawLine(cx+john,cy+paul,cx+bob,cy+billy);
bufferGraphics.drawLine(cx+george,cy+ringo,cx+bob,cy+billy);


bufferGraphics.drawLine(cx-john,cy-paul,cx-george,cy-ringo);
bufferGraphics.drawLine(cx-john,cy-paul,cx-bob,cy-billy);
bufferGraphics.drawLine(cx-george,cy-ringo,cx-bob,cy-billy);


bufferGraphics.drawLine(cx+john,cy-paul,cx+george,cy-ringo);
bufferGraphics.drawLine(cx+john,cy-paul,cx+bob,cy-billy);
bufferGraphics.drawLine(cx+george,cy-ringo,cx+bob,cy-billy);


bufferGraphics.drawLine(cx-john,cy+paul,cx-george,cy+ringo);
bufferGraphics.drawLine(cx-john,cy+paul,cx-bob,cy+billy);
bufferGraphics.drawLine(cx-george,cy+ringo,cx-bob,cy+billy);

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
paul=paul-(i3*popper);
george=george-(i3*pepper);
ringo=ringo+(i3*pepper);
john=john+(i3*popper);
billy=billy-(i3*poopper);
bob=bob+(i3*pepper);


}//i3 loop


   }//end of for loop i
}//double ii loop

     // move the entire buffer onto the display screen and change
     // pixels that are a different color...
      g.drawImage(buffer, 0, 0, this);
    }
} // end of the program...

