From 9617e02d72815acc727bc5b0bc15ef8dfe53f4a5 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Mon, 2 Nov 2020 10:53:43 -0500 Subject: [PATCH] meme: make bully positionable --- plugins/meme/meme.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/meme/meme.go b/plugins/meme/meme.go index 9f0f1fa..27e7f96 100644 --- a/plugins/meme/meme.go +++ b/plugins/meme/meme.go @@ -433,6 +433,7 @@ func (p *MemePlugin) applyBully(img, bullyImg image.Image) image.Image { dst := image.NewRGBA(img.Bounds()) scaleFactor := p.c.GetFloat64("meme.bullyScale", 0.1) + position := p.c.GetString("meme.bullyPosition", "botright") scaleFactor = float64(img.Bounds().Max.X) * scaleFactor / float64(bullyImg.Bounds().Max.X) @@ -446,7 +447,17 @@ func (p *MemePlugin) applyBully(img, bullyImg image.Image) image.Image { w, h := bullyImg.Bounds().Max.X, bullyImg.Bounds().Max.Y - pt := image.Point{srcSz.X - w, srcSz.Y - h} + pt := image.Point{} + switch position { + case "botright": + pt = image.Point{srcSz.X - w, srcSz.Y - h} + case "botleft": + pt = image.Point{0, srcSz.Y - h} + case "topright": + pt = image.Point{srcSz.X - w, 0} + case "topleft": + pt = image.Point{0, 0} + } rect := image.Rect(pt.X, pt.Y, srcSz.X, srcSz.Y) draw.DrawMask(dst, rect, bullyImg, image.Point{}, &circle{image.Point{w / 2, h / 2}, w / 2}, image.Point{}, draw.Over)