Java rotating rectangle

时间:2017-11-11 13:35:11

标签: java swing rotation drawrectangle

im drawing a witch in Java. I finished up with the body and head but now i want to know how I can rotate a rectangle in Java

As you can see on the image below, I need 2 rectangles rotated with a certain degree to visualise the arms of the witch.

Searched for it, but the solutions where too complicated for this.enter image description here

//Body
g.setColor(Blue);
g.fillRect(190, 180, 100, 150);

1 个答案:

答案 0 :(得分:2)

我认为g是一个Graphic对象,然后

Graphics2D myGraphics2D = (Graphics2D)g;
myGraphics2D.rotate(3.14159);  //input in rad... read the doc...