refactor: 重构数据库逻辑
This commit is contained in:
@@ -7,9 +7,9 @@ import (
|
||||
"github.com/fogleman/gg"
|
||||
)
|
||||
|
||||
func GenerateCongratulationImage(text string, outputFile string) {
|
||||
func GenerateCongratulationImage(text string, inputFile, outputFile string, isGood bool) {
|
||||
// 加载喜报背景图片
|
||||
im, err := gg.LoadImage("./resource/xibao_background.png") // 需要提前准备的背景图片
|
||||
im, err := gg.LoadImage(inputFile) // 需要提前准备的背景图片
|
||||
if err != nil {
|
||||
log.Print("无法加载喜报图片:", err)
|
||||
return
|
||||
@@ -28,10 +28,12 @@ func GenerateCongratulationImage(text string, outputFile string) {
|
||||
log.Print("无法加载字体:", err)
|
||||
return
|
||||
}
|
||||
|
||||
// 设置文本颜色为红色
|
||||
dc.SetRGB(1, 0, 0)
|
||||
|
||||
if isGood {
|
||||
// 设置文本颜色为红色
|
||||
dc.SetRGB(1, 0.1, 0.1)
|
||||
} else {
|
||||
dc.SetRGB(0.1, 0.1, 1)
|
||||
}
|
||||
// 将文本按 \n 分割为多行
|
||||
lines := strings.Split(text, "\n")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user