@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 def lc = new LinearColormap((int)0xFFF24405, (int)0xFFF7E967) def gr = img.createGraphics() def dc = (float)1/Math.ceil(img.getHeight()/interval) float colorpos = 0f for(int ly=0;ly<img.getHeight();ly+=interval){ gr.setColor(new Color(lc.getColor(colorpos))) colorpos += dc for(int lx=0;lx<img.getWidth();lx+=interval){ gr.fillRect(lx+padding, ly+padding, tilesize, tilesize) } } ImageIO.write(img, "png", new File("drawgradienttiles.png"))
出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment