带图像的java fillRect方法
我试图使用Java中的fillRect
方法来用图像填充矩形。有没有办法用fillRect
方法来做这件事
以下是我正在编写的代码:
private int x = 0;
private int y = 0;
static int WIDTH = 1;
static int HEIGHT = 1;
private Image image = new ImageIcon("Golf_green.png").getImage();
public BackGround() {
WIDTH = 30;
HEIGHT = 30;
}
public void paint(Graphics2D g) {
g.drawImage(image, x, y, WIDTH, HEIGHT, "BLACK", , arg7, arg8, );
}
# 1 楼答案
没有
取而代之的是,在查看区域的宽度和高度上平铺图像。要获得仅适用于特定矩形的效果,请将该矩形设置为剪辑(在平铺之前)