@Grab(group='org.codehaus.griffon', module='jsilhouette-geom', version='0.4') import java.awt.* import java.awt.image.* import java.io.* import javax.imageio.* import org.codehaus.griffon.jsilhouette.geom.* // 点状の放射ストライプを描画する def img = new BufferedImage( 200, 200, BufferedImage.TYPE_INT_ARGB ) def gr = img.createGraphics() gr.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ) def radius = 200 def nrays = 10 def rays = new Rays(img.getWidth()/2, img.getHeight()/2, radius, nrays ) gr.setColor(new Color((int)0xccddff)) gr.fill(rays) gr.dispose() def buf = new int[4] buf[0] = buf[1] = buf[2] = buf[3] = 0 def wr = img.getRaster() for(int ly=0;ly<wr.getHeight();ly++){ for(int lx=0;lx<wr.getWidth();lx++){ if( lx%2 == 1 || ly%2 == 0 ){ wr.setPixel(lx, ly, buf) } } } ImageIO.write(img, "png", new File("drawdottedrays.png"))
出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment