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 color1 = 0x335599 def interval = 3 def wr = img.getRaster() def buf = new int[4] for(int ly=0;ly<wr.getHeight();ly++){ for(int lx=0;lx<wr.getWidth();lx++){ if( lx%interval == 0 && ly%interval == 0 ){ buf[0] = (color1 >> 16) & 0xff buf[1] = (color1 >> 8) & 0xff buf[2] = color1 & 0xff buf[3] = 255-Math.sin(Math.PI*lx/img.getWidth())*255 } else { buf[0] = buf[1] = buf[2] = buf[3] = 0 } wr.setPixel(lx, ly, buf) } } ImageIO.write(img, "png", new File("hgraddots.png"))
出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment