2016-02-19 04:53:47 +01:00
|
|
|
package main
|
|
|
|
|
2016-02-19 20:03:52 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/fogleman/gg"
|
|
|
|
)
|
2016-02-19 04:53:47 +01:00
|
|
|
|
|
|
|
func main() {
|
2016-02-19 15:43:37 +01:00
|
|
|
dc := gg.NewContext(1000, 1000)
|
2016-02-19 17:07:25 +01:00
|
|
|
dc.SetRGB(1, 1, 1)
|
|
|
|
dc.Clear()
|
|
|
|
dc.SetRGB(0, 0, 0)
|
2016-02-19 20:03:52 +01:00
|
|
|
dc.LoadFontFace("/Library/Fonts/Arial.ttf", 96)
|
2016-02-19 04:53:47 +01:00
|
|
|
s := "Hello, world!"
|
2016-02-19 20:03:52 +01:00
|
|
|
w, h := dc.MeasureString(s)
|
|
|
|
fmt.Println(w, h)
|
|
|
|
dc.DrawString(500-w/2, 500+h/2, s)
|
2016-02-19 19:54:55 +01:00
|
|
|
dc.SavePNG("out.png")
|
2016-02-19 04:53:47 +01:00
|
|
|
}
|