如何在Java2D中旋转矩形 [英] how to rotate a rectangle in Java2D

查看:76
本文介绍了如何在Java2D中旋转矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想旋转一个方法中的矩形,但不了解如何操作,并尝试如下:

I want to rotate a rectangle in a method but do not understand how to do it and tried as follows:

private void setBoundaryRotate(Rectangle b, int radio) {
        AffineTransform transform = new AffineTransform();
        transform.rotate(Math.toRadians(45), b.getX() + b.width/2, b.getY() + b.height/2);}

谢谢大家.

推荐答案

您需要调用

You need to call the transform() method on your transform object, passing in the co-ordinates of your rectangle in an array.

这篇关于如何在Java2D中旋转矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆