Adding a circle shape to Path2D

So, to add a rectangle to the path, you can do this

    Path2D rect = new Path2D.Double();
    rect.append(new Rectangle(10, 10, 100, 10), true);

      

I want to do something like this:

    Path2D circ = new Path2D.Double();
    circ.append(new Circle(... params) true);

      

Is there a way to do this? Thank.

+3


source to share


1 answer


You would use Ellipse2D and give it symmetric parameters.

eg..,



circ.append(new Ellipse2D.Double(x, y, w, h), true); // where w == h

      

To see all the classes that inherit from java.awt.Shape , check its API .

+3


source







All Articles