import java.io.* import java.awt.* import java.awt.geom.* import java.awt.image.* import javax.imageio.* // レンガ模様を描画する def img = new BufferedImage( 200, 200, BufferedImage.TYPE_INT_ARGB ) def brickwidth = 20 def brickheight = 10 def padding = 2 def xinterval = brickwidth + padding def yinterval = brickheight + padding def gr = img.createGraphics() gr.setColor(new Color((int)0xCCB18E)) def rc = 0 for(int ly=0;ly<img.getHeight();ly+=yinterval){ for(int lx=0;lx<img.getWidth();lx+=xinterval){ gr.fillRect((int)lx-(rc%2==0?0:brickwidth/2), ly, brickwidth, brickheight) } rc++; } gr.dispose() ImageIO.write(img, "png", new File("drawbrick.png"))
出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment