Skip to content

Commit

Permalink
增加返回值
Browse files Browse the repository at this point in the history
  • Loading branch information
lvpengc committed Oct 21, 2020
1 parent 4e8c9e5 commit 6f4df07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions foundation/avatar.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ var colors = []uint32{
0xff6200, 0x42c58e, 0x5a8de1, 0x785fe0,
}
//生成头像的方式
func GeneraterAvater(width int,height int,content string) []byte {
func GenerateAvatar(width int,height int,content string)( []byte,error) {
ab := calc.NewAvatarBuilder("../static/SourceHanSansSC-Medium.ttf", &calc.SourceHansSansSCMedium{})
ab.SetBackgroundColorHex(colors[3])
ab.SetFrontgroundColor(color.White)
ab.SetFontSize(80)
ab.SetAvatarSize(width, height)
if data,err:=ab.GenerateImage(content);err==nil {
return data
data,err:=ab.GenerateImage(content)
if err!=nil {
return data,err
}
return nil
return nil,err
}
2 changes: 1 addition & 1 deletion foundation/avatar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import (

func Test_ge(t *testing.T) {

GeneraterAvater()
GenerateAvatar()

}

0 comments on commit 6f4df07

Please sign in to comment.