@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 = ImageIO.read(new File("sf2.jpg")) def img2 = new BufferedImage( img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_ARGB ) def gr = img2.createGraphics() gr.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ) def radius = 100 def angle = 0 def astroid = new Astroid(img.getWidth()/2, img.getHeight()/2, radius, angle ) gr.setColor(new Color(1F, 1F, 1F, 1F)) gr.fill(astroid) // 切り取り gr.setComposite(AlphaComposite.SrcIn) gr.drawImage(img,0,0,null) gr.dispose() ImageIO.write(img2, "png", new File("astroid.png"))元画像 出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment