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 interval = 10 def buf = new int[4] Color color1 = new Color((int)0xF27405) buf[0] = color1.getRed() buf[1] = color1.getGreen() buf[2] = color1.getBlue() buf[3] = 255 def wr = img.getRaster() for(int ly=0;ly<wr.getHeight();ly+=interval){ def cc=((int)ly/interval)%2==0?0:1 for(int lx=0;lx<wr.getWidth();lx+=interval){ if( cc%2 == 0 ){ for(int py=0;py<interval;py++){ for(int px=0;px<interval;px++){ if( (py+px)%2 == 0 )wr.setPixel(lx+px, ly+py, buf) } } } cc++ } } ImageIO.write(img, "png", new File("drawcheckpattern.png"))
出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment