Java 交叉剖面线纹理
有人知道如何在 Java 中重新创建交叉哈希纹理吗? 下面的 C# 代码展示了如何为 .NET 框架完成此任务。 Java 片段很接近,但我无法正确地将线旋转 45 度。
C#
HatchBrush crossHatch =
new HatchBrush(HatchStyle.Cross, somecolor, somecolor);
Java
BufferedImage bufferedImage =
new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = bufferedImage.createGraphics();
g2.setColor(Color.BLUE);
g2.fillRect(0, 0, 5, 5);
g2.setColor(pinColor);
g2.fillOval(0, 0, 5, 5);
// paint with the texturing brush
Rectangle2D rect = new Rectangle2D.Double(0, 0, 5, 5);
g2d.setPaint(new TexturePaint(bufferedImage, rect));
g2d.fill(shape);
提前致谢。
Any know how to recreate a cross hashing texture in Java? The C# code belows shows how to accomplish this for the .NET framework. The Java snippet is close, but I've been unable to correctly rotate the lines by 45 degrees.
C#
HatchBrush crossHatch =
new HatchBrush(HatchStyle.Cross, somecolor, somecolor);
Java
BufferedImage bufferedImage =
new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = bufferedImage.createGraphics();
g2.setColor(Color.BLUE);
g2.fillRect(0, 0, 5, 5);
g2.setColor(pinColor);
g2.fillOval(0, 0, 5, 5);
// paint with the texturing brush
Rectangle2D rect = new Rectangle2D.Double(0, 0, 5, 5);
g2d.setPaint(new TexturePaint(bufferedImage, rect));
g2d.fill(shape);
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面是应以 5 像素间隔绘制交叉影线的一个:
Here's one that should cross-hatch at 5-pixel intervals: