渐变绘画旋转
我有一个形状,它绕其一端旋转,并用渐变涂料着色。
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);
我遇到的问题是,当我旋转形状时,它会脱离设置的渐变。关于如何随形状旋转渐变有什么想法吗?
I have a shape that rotates around one end of itself coloured in by a gradient paint.
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);
The problem i have is that when i rotate the shape it move out of the set gradient. Any idea's on how to rotate the gradient with the shape?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论