gg/examples/text.go

17 lines
330 B
Go
Raw Normal View History

2016-02-19 04:53:47 +01:00
package main
2016-02-20 03:35:56 +01:00
import "github.com/fogleman/gg"
2016-02-19 04:53:47 +01:00
func main() {
2016-02-20 03:35:56 +01:00
const S = 1024
dc := gg.NewContext(S, S)
2016-02-19 17:07:25 +01:00
dc.SetRGB(1, 1, 1)
dc.Clear()
dc.SetRGB(0, 0, 0)
2016-03-05 20:46:55 +01:00
if err := dc.LoadFontFace("/Library/Fonts/Arial.ttf", 96); err != nil {
panic(err)
}
2016-02-20 03:35:56 +01:00
dc.DrawStringAnchored("Hello, world!", S/2, S/2, 0.5, 0.5)
2016-02-19 19:54:55 +01:00
dc.SavePNG("out.png")
2016-02-19 04:53:47 +01:00
}