Tuesday, July 14, 2009

groovyで引っかいたような文字列を描画する

groovyで引っかいたような文字列を描画するには、以下のコードを実行します。


import groovy.swing.j2d.*

sw = 220
sh = 70
gr = new GraphicsRenderer()
img = gr.render(sw, sh){
background(color: color("#ffffff"))
rect(x:0, y:0, width: sw, height: sh){
filters {
scratch(angle:10, angleVariation:0.8,
color: color("#000000"), density:0.7,
length:0.5, width:0.5, seed:2009)
}
}
}
gr.renderToFile("sample1130a.png", sw, sh){
antialias("on")
background(color: color("#000000"))
font(new java.awt.Font('Tahoma', java.awt.Font.BOLD, 60))
text( x:0, y:0, text: "Groovy", borderColor:no){
texturePaint(x: 0, y: 0, image: img )
}
}


出力画像(sample1130a.png)
GraphicsRendererで描画した引っかいたような文字列

No comments: