Skip to content

Instantly share code, notes, and snippets.

@fogleman
Created February 24, 2016 02:56
Show Gist options
  • Save fogleman/9cff4addf4d452f8657d to your computer and use it in GitHub Desktop.
Save fogleman/9cff4addf4d452f8657d to your computer and use it in GitHub Desktop.
Meme-style Text
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")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment