import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class atoy15 extends Applet
   implements MouseListener, MouseMotionListener {

   int width, height;
   int mx, my;  // the mouse coordinates
   boolean isButtonPressed = false;
int rr,gg,bb;
int dx,dy;
int xx,yy;

int q=1;
int q10;



   public void init() {
      width = getSize().width;
      height = getSize().height;
      setBackground( Color.black );

      mx = width/2; //changes to new position
      my = height/2;
      dx = width/2; //center of screen
      dy = height/2;

      addMouseListener( this );
      addMouseMotionListener( this );
   }

   public void mouseEntered( MouseEvent e ) {
      // called when the pointer enters the applet's rectangular area
   }
   public void mouseExited( MouseEvent e ) {
      // called when the pointer leaves the applet's rectangular area
   }
   public void mouseClicked( MouseEvent e ) {
      // called after a press and release of a mouse button
      // with no motion in between
      // (If the user presses, drags, and then releases, there will be
      // no click event generated.)
   }
   public void mousePressed( MouseEvent e ) {  // called after a button is pressed down
      isButtonPressed = true;
      setBackground( Color.black );




q=q+1;
if(q>8){q=1;}



      repaint();
      // "Consume" the event so it won't be processed in the
      // default manner by the source which generated it.
      e.consume();
   }
   public void mouseReleased( MouseEvent e ) {  // called after a button is released
      isButtonPressed = false;
      setBackground( Color.black );
      repaint();
      e.consume();
   }
   public void mouseMoved( MouseEvent e ) {  // called during motion when no buttons are down
      mx = e.getX();
      my = e.getY();
      showStatus( "Mouse at (" + mx + "," + my + ")" );
      repaint();
      e.consume();
   }
   public void mouseDragged( MouseEvent e ) {  // called during motion with buttons down
      mx = e.getX();
      my = e.getY();
      showStatus( "Mouse at (" + mx + "," + my + ")" );
      repaint();
      e.consume();
   }

   public void paint( Graphics g ) {
      if ( isButtonPressed ) {
         g.setColor( Color.black );
      }
      else {



        
      }


xx=dx-mx;
yy=dy-my;

q10=(q*10);

for(int cat=-q10;cat<q10+1;cat=cat+q)
{





for(int kk=-q10; kk<q10+1; kk=kk+q)
{

rr=rr+1;
if(rr>255){rr=30;}
gg=gg+2;
if(gg>253){gg=30;}
bb=bb+3;
if(bb>250){bb=30;}

 Color cNew = new Color(rr, gg, bb);
  g.setColor(cNew);       
xx=xx+kk+kk-cat-cat;
yy=yy-kk-cat;




//set1
      g.drawRect(dx- xx-q,dy- yy-q, q+q, q+q );
g.drawRect(dx+ xx-q,dy+ yy-q, q+q, q+q );
      g.drawRect(dx+ xx-q,dy- yy-q, q+q, q+q );
g.drawRect(dx- xx-q,dy+ yy-q, q+q, q+q );
//set2
      g.drawRect(dx- yy-q,dy- xx-q, q+q, q+q );
g.drawRect(dx+ yy-q,dy+ xx-q, q+q, q+q);
      g.drawRect(dx+ yy-q,dy- xx-q, q+q, q+q );
g.drawRect(dx- yy-q,dy+ xx-q,q+q, q+q );

xx=xx-kk-kk+cat+cat;
yy=yy+kk+cat;

Color bwNew = new Color(gg, bb, rr);
  g.setColor(bwNew);       
xx=xx+kk-cat;
yy=yy-kk-kk-cat-cat;

//set1
      g.drawRect(dx- xx-q,dy- yy-q, q+q, q+q );
g.drawRect(dx+ xx-q,dy+ yy-q, q+q, q+q );
      g.drawRect(dx+ xx-q,dy- yy-q, q+q, q+q );
g.drawRect(dx- xx-q,dy+ yy-q, q+q, q+q );
//set2
      g.drawRect(dx- yy-q,dy- xx-q, q+q, q+q );
g.drawRect(dx+ yy-q,dy+ xx-q, q+q, q+q);
      g.drawRect(dx+ yy-q,dy- xx-q, q+q, q+q );
g.drawRect(dx- yy-q,dy+ xx-q,q+q, q+q );




xx=xx-kk+cat;
yy=yy+kk+kk+cat+cat;
}
}
   }
}
