mirror of https://github.com/velour/catbase.git
Merge pull request #332 from velour/memecaps
meme: add capitalization to configs, true default
This commit is contained in:
commit
c61b84d21b
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue