import javax.imageio.*;
import groovy.swing.j2d.*
img = ImageIO.read(new File("sf.jpg"))
w = img.getWidth()
h = img.getHeight()
gr = new GraphicsRenderer()
imgb = gr.render(w, h){
antialias("on")
rect( x: 0, y: 0, width: w, height: h,
borderColor: no, fill: color("#ffffff")){
}
font(new java.awt.Font('Tahoma', java.awt.Font.BOLD, 120))
text( x:30, y:60, text: "SF", fill: 'black')
}
imgc = gr.render(w, h){
antialias("on")
rect( x: 0, y: 0, width: w, height: h,
borderColor: no){
texturePaint(x: 0, y: 0, image: imgb )
filters {
gaussianBlur(radius:6)
}
}
}
gr.renderToFile("sample1007a.png", w, h){
antialias("on")
rect( x: 0, y: 0, width: w, height: h,
borderColor: no){
texturePaint(x: 0, y: 0, image: img )
filters {
displace(amount:0.5, displacementMap: imgc, edgeAction:'clamp')
}
}
}
元画像(sf.jpg)
出力画像(sample1007a.png)
動作環境
Groovy1.6.0, JDK1.6 Update12
関連項目
groovyで透明な文字列を描画する
Java2DとJava Image Filters(pixels)を使用して文字列をガラスのように描画する
No comments:
Post a Comment