@Grab(group='com.jhlabs', module='filters', version='2.0.235') import java.awt.* import java.awt.image.* import java.io.* import javax.imageio.* import com.jhlabs.composite.* import com.jhlabs.image.* // 渦巻き模様を生成する def img = new BufferedImage( 200, 200, BufferedImage.TYPE_INT_ARGB ) def gr = img.createGraphics() gr.setColor(new Color((int)0xccddff)) gr.fillRect(0, 0, (int)img.getWidth(), (int)img.getHeight()/2) gr.setColor(new Color((int)0xffffff)) gr.fillRect(0, (int)img.getHeight()/2, (int)img.getWidth(), (int)img.getHeight()/2) gr.dispose() def tf = new TwirlFilter() // 角度 tf.setAngle((float)ImageMath.PI*7200/360) // 中央座標X tf.setCentreX(0.5f) // 中央座標Y tf.setCentreY(0.5f) // 半径 tf.setRadius( (float)img.getWidth()>img.getHeight()?img.getWidth():img.getHeight() ) img = tf.filter(img, null) ImageIO.write(img, "png", new File("spiral.png"))
出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment