From 8dc1d89666a06174f7b7b2840feb89233a09e61b Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Tue, 23 Feb 2016 22:25:43 -0500 Subject: [PATCH] meme text example --- examples/meme.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/meme.go diff --git a/examples/meme.go b/examples/meme.go new file mode 100644 index 0000000..b6db789 --- /dev/null +++ b/examples/meme.go @@ -0,0 +1,28 @@ +package main + +import "github.com/fogleman/gg" + +func main() { + const S = 1024 + dc := gg.NewContext(S, S) + dc.SetRGB(1, 1, 1) + dc.Clear() + dc.LoadFontFace("/Library/Fonts/Impact.ttf", 96) + dc.SetRGB(0, 0, 0) + s := "ONE DOES NOT SIMPLY" + n := 6 // "stroke" size + for dy := -n; dy <= n; dy++ { + for dx := -n; dx <= n; dx++ { + if dx*dx+dy*dy >= n*n { + // give it rounded corners + continue + } + x := S/2 + float64(dx) + y := S/2 + float64(dy) + dc.DrawStringAnchored(s, x, y, 0.5, 0.5) + } + } + dc.SetRGB(1, 1, 1) + dc.DrawStringAnchored(s, S/2, S/2, 0.5, 0.5) + dc.SavePNG("out.png") +}