@Grab(group='com.jhlabs', module='filters', version='2.0.235') @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 com.jhlabs.composite.* import com.jhlabs.image.* 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 radius1 = 100 def radius2 = 50 def angle = 0 def scale = 5 def star = new Star(img.getWidth()/2, img.getHeight()/2, radius1, radius2, 5, angle ) gr.setColor(new Color((int)0xeedd00)) gr.fill(star) gr.dispose() def df = new DiffuseFilter() df.setScale((int)scale) img = df.filter(img, null) def mf = new MedianFilter() img = mf.filter(img, null) img = mf.filter(img, null) ImageIO.write(img, "png", new File("drawstarhand.png"))
出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment