gg/examples/text.go

16 lines
304 B
Go
Raw Normal View History

2016-02-19 04:53:47 +01:00
package main
2016-02-19 15:43:37 +01:00
import "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 04:53:47 +01:00
dc.LoadFontFace("/Library/Fonts/Impact.ttf", 96)
s := "Hello, world!"
w := dc.MeasureString(s)
dc.DrawString(500-w/2, 500, s)
dc.WriteToPNG("out.png")
}