import java.awt.* import java.awt.image.* import java.awt.geom.* import java.io.* import javax.imageio.* // ストライプ枠を描画する def img = ImageIO.read(new File("sf2.jpg")) def bwidth = 10 def img2 = new BufferedImage( img.getWidth()+bwidth*2, img.getHeight()+bwidth*2, BufferedImage.TYPE_INT_ARGB ) def gr = img2.createGraphics() gr.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ) def dx = 200 def linewidth = 16 def interval = 44 gr.setColor(new Color((int)0x26261E)) gr.fillRect(0, 0, img2.getWidth(), img2.getHeight()) gr.setStroke(new BasicStroke(linewidth)) gr.setColor(new Color((int)0xffc92c)) for(int lx=-dx;lx<(img2.getWidth());lx+=interval){ gr.drawLine(lx, 0, lx+dx, img2.getHeight()) } gr.drawImage(img, bwidth, bwidth, null) gr.dispose() ImageIO.write(img2, "png", new File("stripeborder.png"))
元画像
出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment