package main import ( "image/color" "log" "github.com/fogleman/gg" ) type ctx struct { dc *gg.Context } func (c *ctx) moveTo(x, y float32) { c.dc.MoveTo(float64(x), float64(y)) } func (c *ctx) lineTo(x, y float32) { c.dc.LineTo(float64(x), float64(y)) } func (c *ctx) draw(argb uint32) { c.dc.SetColor(color.NRGBA{ A: uint8((argb >> 24) & 0xff), R: uint8((argb >> 16) & 0xff), G: uint8((argb >> 8) & 0xff), B: uint8(argb & 0xff), }) c.dc.Fill() c.dc.ClearPath() } func (c *ctx) writePng(fn string) { if err := c.dc.SavePNG(fn); err != nil { log.Fatal(err) } } func main() { ctx := ctx{gg.NewContext(1280, 720)} parse(&ctx) ctx.writePng("gg.png") }