code: private int[] rect() {
  		 if(np==0)return null;
  		int xMin = x[0], yMin=y[0], xMax=x[0],yMax=y[0];
  
  		 for(int i=1;i<np;i++) {
  			 if(x[i]<xMin)xMin=x[i];
  			 else if(x[i]>xMax)xMax=x[i];
  			 if(y[i]<yMin)yMin=y[i];
  			 else if(y[i]>yMax)yMax=y[i];
  		 }
  
  		 return new int[] { xMin, yMin, xMax-xMin, yMax-yMin };
  	}
docs: Calculates the origin (X, Y) and the width and height
  of a rectangle that contains all the segments of the
  polyline.