@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 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 lc = new LinearColormap(0xeedd00, 0xffffff) def sf = new ShapeFilter() sf.setColormap(lc) img = sf.filter(img, null) ImageIO.write(img, "png", new File("drawstar2.png"))
出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment