@Grab(group='com.jhlabs', module='filters', version='2.0.235') import java.io.* import java.awt.* import java.awt.geom.* import java.awt.image.* import javax.imageio.* import com.jhlabs.image.* // ぼかした水玉模様を描画する def img = new BufferedImage( 200, 200, BufferedImage.TYPE_INT_RGB ) def gr = img.createGraphics() def radius = 9 def padding = 4 def interval = radius*2 + padding gr.setColor(new Color(0xffffff)) def rect = new Rectangle2D.Double( 0.0, 0.0, img.getWidth(), img.getHeight()) gr.fill(rect) gr.setColor(new Color(0x7799dd)) def rc = 0 for(int ly=0;ly<img.getHeight();ly+=interval){ for(int lx=0;lx<img.getWidth()+radius;lx+=interval){ def rr = new Ellipse2D.Double( lx-((rc%2==0)?0:interval/2), ly, radius*2, radius*2) gr.fill(rr) } rc++; } def gf = new GaussianFilter() gf.setRadius(5f) img = gf.filter(img, null) ImageIO.write(img, "png", new File("drawblurreddots.png"))
出力画像
動作環境
groovy 1.8.6, JDK7 update4