0
我開始在java中構建一個模擬並使用矩形作爲平面。但是當我旋轉矩形時,它的前景色不會粘在它上面。有人能幫我嗎?使用顏色旋轉矩形
截圖:Here
源代碼:
private void drawTransform(Graphics g, double modifier) {
Rectangle rect = new Rectangle(130,350, 350, 15);
AffineTransform at = new AffineTransform();
at.rotate(-Math.toRadians(modifier), rect.getX(), rect.getY() + rect.height);
// Transform the shape and draw it to screen
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.red);
g2d.fillRect(130, 350, 350, 15);
g2d.draw(at.createTransformedShape(rect));
}