@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_ARGB ) def tilesize = 16 def padding = 2 def interval = tilesize + padding*2 Color color1 = new Color((int)0x5E728C) def gr = img.createGraphics() gr.setColor(color1) for(int ly=0;ly<img.getHeight();ly+=interval){ for(int lx=0;lx<img.getWidth();lx+=interval){ gr.fillRect(lx+padding, ly+padding, tilesize, tilesize) } } def df = new DiffuseFilter() df.setScale((int)padding) img = df.filter(img, null) def mf = new MedianFilter() img = mf.filter(img, null) ImageIO.write(img, "png", new File("drawtileshand.png"))
出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment