Skip to content

Commit

Permalink
add: tip
Browse files Browse the repository at this point in the history
  • Loading branch information
RicheyJang committed Aug 5, 2022
1 parent 237eb9b commit ee1e537
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion basic/help/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func formSummaryHelpMsg(isSuper, isPrimary bool, priority int, blackKeys map[str
blocks[i].colNum = cols
}
w = math.Max(w, maxSingleW*float64(cols)+20*float64(cols-1)) // 多列,取最大框宽度的n倍
w, h = w+30, h+maxH+40
w, h = w+30, h+maxH+40+20
// 贴提示文字
img := images.NewImageCtxWithBGRGBA255(int(w), int(h), 255, 255, 255, 255)
err := img.PasteStringDefault(headTips, 24, 1.3, 10, 20, w)
Expand All @@ -101,6 +101,7 @@ func formSummaryHelpMsg(isSuper, isPrimary bool, priority int, blackKeys map[str
img.DrawImage(block.img, nowX, nowY)
nowY += int(block.h) + 40
}
img.PasteWatermark(w-50, h-15, 22, "#b8b8b8")
msg, err := img.GenMessageAuto()
if err != nil {
return message.Text(helps.String())
Expand Down
9 changes: 9 additions & 0 deletions utils/images/paste.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ func (img *ImageCtx) PasteRoundedRectangle(x, y, w, h, r float64, colorStr strin
img.Fill()
}

// PasteWatermark 绘制水印,右下角定位
func (img *ImageCtx) PasteWatermark(x, y, fontsize float64, color string) {
if err := img.UseDefaultFont(fontsize); err != nil {
return
} // 默认字体
img.SetColorAuto(color)
img.DrawStringAnchored("By RicheyJang's PaimengBot", x, y, 1, 0)
}

type Point struct {
X, Y float64
}
Expand Down

0 comments on commit ee1e537

Please sign in to comment.