Skip to content

Instantly share code, notes, and snippets.

@yenjoji
Created April 4, 2013 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yenjoji/5310058 to your computer and use it in GitHub Desktop.
Save yenjoji/5310058 to your computer and use it in GitHub Desktop.
どうでもいいテスト用の画像ファイルを生成するGroovy
import java.awt.*
import java.awt.image.*
import javax.imageio.*
long lastmod = System.currentTimeMillis()
(1..2000).each{
def bi = new BufferedImage(2048, 1364, BufferedImage.TYPE_INT_RGB)
def g = bi.createGraphics()
g.setBackground(Color.black)
int fontsize = 1200 / Math.max( 1 , ( Math.round(Math.log10(it) + 0.5) -2 ) )
g.setFont(new Font("Monospaced", Font.PLAIN, fontsize))
g.setColor(Color.white)
g.drawString("${it}", 200, 1182 )
def out = new File("/tmp/testimg/${it}.jpg")
ImageIO.write(bi, "jpg", out)
out.setLastModified(lastmod - ( 1000L * 60 * 60 * 24 * it))
print "."
if(it % 10 == 0){
println ""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment