有人知道如何在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);提前谢谢。
发布于 2009-04-27 19:13:24
这是一个应该以5像素的间隔交叉阴影的代码:
BufferedImage bufferedImage =
new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = bufferedImage.createGraphics();
g2.setColor(backColor);
g2.fillRect(0, 0, 5, 5);
g2.setColor(stripeColor);
g2.drawLine(0, 0, 5, 5); // \
g2.drawLine(0, 5, 5, 0); // /
// paint with the texturing brush
Rectangle2D rect = new Rectangle2D.Double(0, 0, 5, 5);
g2d.setPaint(new TexturePaint(bufferedImage, rect));
g2d.fill(shape);https://stackoverflow.com/questions/794780
复制相似问题