简体   繁体   中英

How can I rotate a Rectangle?

I'm attempting to rotate a Rectangle (the Java class) created with

Rectangle rect = new Rectangle(x, y, width, height);

I cannot appear to find anything in the API for it. If I google "Java rotate a rectangle", then I can only find threads telling me how to draw it rotated, and not just rotate the object.

AffineTransform.getRotateInstance(angle).createTransformedShape(rect) creates a Shape representing the rotated rectangle. (It can't return another Rectangle because Rectangle expects to just be straight along the x/y axes.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM