1

我有一个形状,它围绕自身的一端旋转,由渐变涂料着色。

GradientPaint turretShade = new GradientPaint(Math.round(x+((1.0/2.0)*le)),Math.round(y+((1.0/2.0)*le)),green,
                                                Math.round(x+((1.0/2.0)*le)), Math.round(y+((1.0/2.0)*le)+(1.0/10.0)*le)
                                                ,new Color(0x1A3C12));
g2d.setPaint(turretShade);


Rectangle2D rect = new Rectangle2D.Double(0,-(0.5/10.0)*le,(3.0/4.0)*le,(1.0/10.0)*le);
g.clearRect(0,0,1000,1000);
AffineTransform transform = new AffineTransform();
transform.translate(x+((1.0/2.0)*le),y+((1.0/2.0)*le)+(0.5/10.0)*le);
transform.rotate(Math.toRadians(turretang));
Shape rotateRect = transform.createTransformedShape(rect);
g2d.fill(rotateRect);
transform.translate(0,0);

我遇到的问题是,当我旋转形状时,它会移出设置的渐变。关于如何用形状旋转渐变的任何想法?

4

0 回答 0