private Polygon rectangleShadow(int x, int y, int shapeX, int shapeY, int width, int height) {
    int[] xPoints = {0, 0, 0, 0, 0};
    int[] yPoints = {0, 0, 0, 0, 0};
    //Left side of screen
    if (x > shapeX + width) {
      
      //top
      if (y > shapeY + height) {
        xPoints = new int[] {shapeX,
                             shapeX,
                             shapeX + width,
                             shapeX + width - (x - (shapeX + width))*10,
                             shapeX - (x - shapeX)*10};
        
        yPoints = new int[] {shapeY + height, 
                             shapeY, 
                             shapeY,
                             shapeY - (y - shapeY)*10,
                             shapeY + height - (y - (shapeY + height))*10};
      }
      
      //bottom
      else if (y < shapeY) {
          xPoints = new int[] {shapeX,
                               shapeX,
                               shapeX + width,
                               shapeX + width - (x - (shapeX + width))*10,
                               shapeX - (x - shapeX)*10};

          yPoints = new int[] {shapeY, 
                               shapeY + height, 
                               shapeY + height,
                               shapeY + height - (y - (shapeY + height))*10,
                               shapeY - (y - shapeY)*10};
      }
      
      //left
      else {
        xPoints = new int[]{shapeX + width, 
                            shapeX, 
                            shapeX, 
                            shapeX + width, 
                            shapeX + width - (x - (shapeX + width))*10, 
                            shapeX + width - (x - (shapeX + width))*10};
      
        yPoints = new int[]{shapeY + height, 
                            shapeY + height, 
                            shapeY, 
                            shapeY,
                            shapeY - (y - shapeY)*10,
                            shapeY + height - (y - (shapeY + height))*10};
      } 
    
    }

      //Right side of screen
    else if (x < shapeX) {
        
        //top
        if (y > shapeY + height) {
          xPoints = new int[] {shapeX,
                               shapeX + width,
                               shapeX + width,
                               shapeX + width - (x - (shapeX + width))*10,
                               shapeX - (x - shapeX)*10};
          
          yPoints = new int[] {shapeY, 
                               shapeY, 
                               shapeY + height,
                               shapeY + height - (y - (shapeY + height))*10,
                               shapeY - (y - shapeY)*10};
        }
        
        //bottom
        else if (y < shapeY) {
            xPoints = new int[] {shapeX + width,
                                 shapeX + width,
                                 shapeX,
                                 shapeX - (x - (shapeX))*10,
                                 shapeX + width - (x - (shapeX + width))*10};

            yPoints = new int[] {shapeY, 
                                 shapeY + height, 
                                 shapeY + height,
                                 shapeY + height - (y - (shapeY + height))*10,
                                 shapeY - (y - shapeY)*10};
        }
        
        //Right
        else {
          xPoints = new int[]{shapeX, 
                              shapeX + width, 
                              shapeX + width, 
                              shapeX, 
                              shapeX - (x - shapeX)*10, 
                              shapeX - (x - shapeX)*10};
        
          yPoints = new int[]{shapeY, 
                              shapeY, 
                              shapeY + height, 
                              shapeY + height,
                              shapeY + height - (y - (shapeY + height))*10,
                              shapeY - (y - (shapeY))*10};
        
        }
      }
    
    //middle
    else{
      if(y > shapeY + height){
        xPoints = new int[]{shapeX, 
                            shapeX, 
                            shapeX + width, 
                            shapeX + width, 
                            shapeX + width - (x - (shapeX + width))*10, 
                            shapeX - (x - shapeX)*10};

        yPoints = new int[]{shapeY + height, 
                            shapeY, 
                            shapeY, 
                            shapeY + height,
                            shapeY + height - (y - (shapeY + height))*10,
                            shapeY + height- (y - (shapeY + height))*10};
      }
      else if(y < shapeY){
        xPoints = new int[]{shapeX, 
                            shapeX, 
                            shapeX + width,   
                            shapeX + width, 
                            shapeX + width - (x - (shapeX + width))*10, 
                            shapeX - (x - shapeX)*10};

        yPoints = new int[]{shapeY, 
                            shapeY + height, 
                            shapeY + height, 
                            shapeY,
                            shapeY - (y - shapeY)*10,
                            shapeY - (y - shapeY)*10};
      }
    }
    
      
    return new Polygon(xPoints, yPoints, xPoints.length);
  }