meme: add capitalization to configs, true default

fixes #331
This commit is contained in:
Chris Sexton 2021-01-09 15:27:00 -05:00
parent f1aa4ebeb2
commit 8d52a3d1bd
2 changed files with 10 additions and 3 deletions

View File

@ -42,6 +42,7 @@ type memeText struct {
XPerc float64 `json:"x"`
YPerc float64 `json:"y"`
Text string `json:"t"`
Caps bool `json:"c"`
}
var horizon = 24 * 7
@ -329,8 +330,8 @@ func (p *MemePlugin) findFontSize(config []memeText, w, h int, sizes []float64)
func defaultFormatConfig() []memeText {
return []memeText{
{XPerc: 0.5, YPerc: 0.05},
{XPerc: 0.5, YPerc: 0.95},
{XPerc: 0.5, YPerc: 0.05, Caps: true},
{XPerc: 0.5, YPerc: 0.95, Caps: true},
}
}
@ -395,6 +396,12 @@ func (p *MemePlugin) genMeme(meme string, bully image.Image, config []memeText)
fontLocation := p.c.Get("meme.font", "impact.ttf")
m.LoadFontFace(fontLocation, p.findFontSize(config, w, h, fontSizes))
for i, c := range config {
if c.Caps {
config[i].Text = strings.ToUpper(c.Text)
}
}
// Apply black stroke
m.SetHexColor("#000")
strokeSize := 6

View File

@ -46,7 +46,7 @@ func (p *MemePlugin) all(w http.ResponseWriter, r *http.Request) {
for n, u := range memes {
config, ok := configs[n]
if !ok {
b, _ := json.Marshal(defaultFormatConfig)
b, _ := json.Marshal(defaultFormatConfig())
config = string(b)
}
realURL, err := url.Parse(u)