Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have rotated Ellipse shape in Java?

Tags:

java

awt

ellipse

How to have rotated ellipse Shape in java? I.e. so that its semi-axes are not parallel to coordinate axes?

P.S. I need not just draw this ellipse but have it in memory as a shape object.

like image 266
Suzan Cioc Avatar asked Nov 29 '25 02:11

Suzan Cioc


1 Answers

Just take an Ellipse2D object and apply an AffineTransform rotation to it, no?

AffineTransform.getRotateInstance(Math.PI / 4)
  .createTransformedShape(new Ellipse2D.Double(0, 0, 2, 1));
like image 52
Louis Wasserman Avatar answered Nov 30 '25 16:11

Louis Wasserman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!