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_RGB ) def gr = img.createGraphics() // レンダリングヒントを設定 def rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY) gr.setRenderingHints(rh) def radius = 9 def rc = 0 for(int ly=-radius;ly<img.getHeight();ly+=radius){ for(int lx=((rc%2==0)?0:-radius);lx<img.getWidth();lx+=radius*2){ gr.setColor(new Color(0xffffff)) def rr = new Ellipse2D.Double( lx, ly, radius*2, radius*2) gr.fill(rr) gr.setColor(new Color(0x7799dd)) gr.setStroke(new BasicStroke(3)) gr.draw(rr) } rc++; } gr.dispose() ImageIO.write(img, "png", new File("drawsquama.png"))
出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment