Shape (double x, double y, double width, double height, double arcRatio) { if (width == height && arcRatio == 1.0) { return new Ellipse2D.Double(x, y, width, height); } GeneralPath path = new GeneralPath(); path.moveTo(1, 0); double step = Math.PI / 360; double n = getPower(arcRatio); for (double theta = step; theta <= 2 * Math.PI; theta += step) { path.lineTo( Math.pow(Math.abs(Math.cos(theta)), 2d/n) * Math.signum(Math.cos(theta)), Math.pow(Math.abs(Math.sin(theta)), 2d/n) * Math.signum(Math.sin(theta))); } path.lineTo(1, 0); path.closePath(); AffineTransform transform = AffineTransform.getScaleInstance(width /2 , height / 2); transform.preConcatenate(AffineTransform.getTranslateInstance(x + width/2, y + height/2)); path.transform(transform); return path; }