Groovyではてブカウンター風はてなスターカウンターを作成する   6)カウンターに数字を描く

昨日までに作成したカウンターにはてなスターの数字を合わせる

ソース

import groovy.swing.j2d.*


gr = new GraphicsRenderer()
gr.renderToFile(".\\Graphics\\HatenaStar2.png", 75, 14){
    antialias("on")
    rect(x:0, y:0, width:75, height:14,
        fill: color('#ff9429'),
        borderColor: color('#ffd583'),
        borderWidth:1
    )
    star(cx:7, cy:7, count:5, ir:2, or:4,
         fill: color('#ffdea4'),
    )
    
    /* 3D-ish */
    /* right side of  of star */
    line(x1:14, y1:0, x2:14, y2:14, borderColor:color('#ff7b18'), borderWidth:1)
    /* left side of the rectangle */    
    line(x1:15, y1:0, x2:15, y2:14, borderColor:color('#ffd583'), borderWidth:1)
    /* right side of the rectangle */
    line(x1:74, y1:0, x2:74, y2:14, borderColor:color('#ff7b18'), borderWidth:1)
    /* base of the rectangle */   
    line(x1:0, y1:13, x2:75, y2:13, borderColor:color('#ff7b18'), borderWidth:1)

    
    font(new java.awt.Font('Tahoma', java.awt.Font.BOLD, 10))
    text( x:60 , y:4,
        text: "12",
        fill: 'white',
        borderColor: no,
    )
}

実行結果

===> [import groovy.swing.j2d.*]
===> groovy.swing.j2d.GraphicsRenderer@169da74
===> .\Graphics\HatenaStar2.png

作成された画像


画像としては出来た。


実行環境






最近のキーワード






Groovyイン・アクション
Dierk Konig Andrew Glover Paul King Guillaume Laforge Jon Skeet
毎日コミュニケーションズ
売り上げランキング: 294340




Groovyイン・アクションを読むならあった方が便利かな。

ブックストッパー
ブックストッパー
posted with amazlet at 10.09.18

トモエ算盤
売り上げランキング: 614


Rubyレシピブックは「ほんたった」で立ててる

EDISON ほんたった黒(ハードケース入り)
株式会社エジソン
売り上げランキング: 2164