DEBUG MODE OFF

This commit is contained in:
Hamcha 2016-02-20 23:18:25 +01:00
parent f15f8dcef2
commit ab017b8584
2 changed files with 7 additions and 9 deletions

View file

@ -106,11 +106,8 @@ func (t Telegram) SendPhoto(data tg.ClientPhotoData) {
req.Header.Add("Content-Type", writer.FormDataContentType()) req.Header.Add("Content-Type", writer.FormDataContentType())
resp, err := client.Do(req) _, err = client.Do(req)
checkerr("SendPhoto/http.Do", err) checkerr("SendPhoto/http.Do", err)
defer resp.Body.Close()
respbytes, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(respbytes))
} }
// GetFile sends a "getFile" API call to Telegram's servers and fetches the file // GetFile sends a "getFile" API call to Telegram's servers and fetches the file

View file

@ -98,7 +98,7 @@ func memegen(broker *tg.Broker, update tg.APIMessage) {
gc.Save() gc.Save()
// Detect appropriate font size // Detect appropriate font size
scale := iwidth / iheight * 200 scale := iheight / iwidth * (iwidth / 10)
gc.SetFontSize(scale) gc.SetFontSize(scale)
gc.SetLineWidth(scale / 15) gc.SetLineWidth(scale / 15)
@ -127,15 +127,16 @@ func memegen(broker *tg.Broker, update tg.APIMessage) {
// Still too big? Decrease font size again // Still too big? Decrease font size again
iter := 0 iter := 0
for width > iwidth && iter < 10 { for width > iwidth && iter < 10 {
left, _, right, _ = gc.GetStringBounds(texts[longid]) log.Println("Warning, resizing!")
gc.SetFontSize(scale * 0.8) left, top, right, bottom = gc.GetStringBounds(texts[longid])
gc.SetFontSize(scale * (0.8 - 0.1*float64(iter)))
width = right - left width = right - left
iter++ iter++
} }
} }
height := bottom - top height := bottom - top
margin := float64(10) margin := float64(height / 50)
lines := float64(len(texts) - 1) lines := float64(len(texts) - 1)
gc.Save() gc.Save()
@ -146,7 +147,7 @@ func memegen(broker *tg.Broker, update tg.APIMessage) {
y := float64(0) y := float64(0)
if istop { if istop {
y = (height-margin)*float64(id+1) + margin*5 y = (height+margin)*float64(id+1) + margin*5
} else { } else {
y = iheight - (height * lines) + (height * float64(id)) - margin*5 y = iheight - (height * lines) + (height * float64(id)) - margin*5
} }