我創建了我施加到矩形作爲填充圖案用來塑造S.如果我變化看的位置一個BufferedImage,填充圖案與它的變化而不是保持「固定」。會是什麼呢?填充模式隨對象位置而變化。爪哇
圖片:(該模式是一個3條,都具有相同的縱橫比):alt text http://img88.imageshack.us/img88/8524/imageby.png
if (bannerPatternCreated == false) {
banner = new BufferedImage(size * 3, size * 3, BufferedImage.TYPE_INT_RGB);
Graphics2D gc = banner.createGraphics();
System.out.println("Creating banner...");
gc.setColor(Color.black);
gc.fillRect(0, 0, size, size * 3);
gc.setColor(Color.BLUE);
gc.fillRect(size, 0, size, size * 3);
gc.setColor(Color.WHITE);
gc.fillRect(size * 2, 0, size, size * 3);
gc.dispose();
bannerPatternCreated = true;
}
Rectangle patternPencil = new Rectangle(size, size);
g2.setPaint(new TexturePaint(banner, patternPencil));
Rectangle recto = new Rectangle(presentX-size, presentY-size, size, size);
g2.fill(recto);
如何一點點的代碼? – 2010-05-02 04:55:39