Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Feb 7, 2023
1 parent b226b9f commit 82492b7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 54 deletions.
9 changes: 4 additions & 5 deletions card.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
"strings"

"github.com/FloatTech/gg"
"github.com/FloatTech/zbputils/img"
"github.com/FloatTech/zbputils/img/text"
"github.com/FloatTech/imgfactory"
)

var (
Expand Down Expand Up @@ -37,7 +36,7 @@ func (c *Card) DrawTextCard() (imgForCard image.Image, err error) {
} else {
textString = strings.Join(c.Text, " ")
}
textImg, err := text.Render(textString, fontOfText, width-80, 38)
textImg, err := imgfactory.RenderText(textString, fontOfText, width-80, 38)
if err != nil {
return
}
Expand All @@ -59,9 +58,9 @@ func (c *Card) DrawTextCard() (imgForCard image.Image, err error) {
canvas.SetRGBA255(rand.Intn(45)+165, rand.Intn(45)+165, rand.Intn(45)+165, 255)
canvas.Fill()
} else {
banner, err := img.LoadFirstFrame(c.BackgroundImage, width, imgHigh)
banner, err := imgfactory.LoadFirstFrame(c.BackgroundImage, width, imgHigh)
if err == nil {
canvas.DrawImage(img.Size(banner.Im, width, imgHigh).Im, 0, 0)
canvas.DrawImage(imgfactory.Size(banner.Image(), width, imgHigh).Image(), 0, 0)
}
}
// 标题
Expand Down
12 changes: 1 addition & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,17 @@ go 1.19

require (
github.com/FloatTech/gg v1.1.0
github.com/FloatTech/zbputils v1.6.2-0.20230206130001-6b404926bf66
github.com/FloatTech/imgfactory v0.2.1
github.com/disintegration/imaging v1.6.2
github.com/stretchr/testify v1.8.1
)

require (
github.com/FloatTech/floatbox v0.0.0-20230130095057-3d1da721425e // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 // indirect
github.com/fumiama/cron v1.3.0 // indirect
github.com/fumiama/go-base16384 v1.6.4 // indirect
github.com/fumiama/go-registry v0.2.5 // indirect
github.com/fumiama/go-simple-protobuf v0.1.0 // indirect
github.com/fumiama/gofastTEA v0.0.10 // indirect
github.com/fumiama/imgsz v0.0.2 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/wdvxdr1123/ZeroBot v1.6.8 // indirect
golang.org/x/image v0.3.0 // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/text v0.6.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
28 changes: 2 additions & 26 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,47 +1,27 @@
github.com/FloatTech/floatbox v0.0.0-20230130095057-3d1da721425e h1:RhKDmRNaBXK+lGY9FX+PAm75z03EHXp7y3/F2cZIv58=
github.com/FloatTech/floatbox v0.0.0-20230130095057-3d1da721425e/go.mod h1:OoZE4Ra7olpFaJSrlD6mcyT4chPLg9QBRE1pzTC8R84=
github.com/FloatTech/gg v1.1.0 h1:4qmsleYqRZ/gv48izGgkyJgvP1RmybA5xJJnzkhK/OU=
github.com/FloatTech/gg v1.1.0/go.mod h1:uzPzAeT35egARdRuu+1oyjU3CmTwCceoq3Vvje7LpcI=
github.com/FloatTech/zbputils v1.6.2-0.20230206130001-6b404926bf66 h1:Flhj6lBRDQQnAkRML2pIJEwqSu1NjfS2Tzh0HncaC2Q=
github.com/FloatTech/zbputils v1.6.2-0.20230206130001-6b404926bf66/go.mod h1:cJiEzrjnkGlnw1oyL4wXmF64njoDN/jNV1Qm+Hu3B2o=
github.com/FloatTech/imgfactory v0.2.1 h1:XoVwy0Xu0AvTRtzlhv5teZcuZlAcHrYjeQ8MynJ/zlk=
github.com/FloatTech/imgfactory v0.2.1/go.mod h1:QBJKHbzpE+x/9Wn7mXebWap/K/xUJSjgiaelAElwU9Q=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 h1:BBade+JlV/f7JstZ4pitd4tHhpN+w+6I+LyOS7B4fyU=
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4/go.mod h1:H7chHJglrhPPzetLdzBleF8d22WYOv7UM/lEKYiwlKM=
github.com/fumiama/cron v1.3.0 h1:ZWlwuexF+HQHl3cYytEE5HNwD99q+3vNZF1GrEiXCFo=
github.com/fumiama/cron v1.3.0/go.mod h1:bz5Izvgi/xEUI8tlBN8BI2jr9Moo8N4or0KV8xXuPDY=
github.com/fumiama/go-base16384 v1.6.4 h1:rYDRwD/th2cG4U7QLokpzmST1cCxZGXtHmolOUePt5o=
github.com/fumiama/go-base16384 v1.6.4/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM=
github.com/fumiama/go-registry v0.2.5 h1:Y6tnHnTThQPv7E4JPM2vBprU+4EQw/LEDO33HCmxgI4=
github.com/fumiama/go-registry v0.2.5/go.mod h1:GP45kejHuDLFxcWdksrt75r5rHBqYwtfeUl3JzGWxfQ=
github.com/fumiama/go-simple-protobuf v0.1.0 h1:rLzJgNqB6LHNDVMl81yyNt6ZKziWtVfu+ioF0edlEVw=
github.com/fumiama/go-simple-protobuf v0.1.0/go.mod h1:5yYNapXq1tQMOZg9bOIVhQlZk9pQqpuFIO4DZLbsdy4=
github.com/fumiama/gofastTEA v0.0.10 h1:JJJ+brWD4kie+mmK2TkspDXKzqq0IjXm89aGYfoGhhQ=
github.com/fumiama/gofastTEA v0.0.10/go.mod h1:RIdbYZyB4MbH6ZBlPymRaXn3cD6SedlCu5W/HHfMPBk=
github.com/fumiama/imgsz v0.0.2 h1:fAkC0FnIscdKOXwAxlyw3EUba5NzxZdSxGaq3Uyfxak=
github.com/fumiama/imgsz v0.0.2/go.mod h1:dR71mI3I2O5u6+PCpd47M9TZptzP+39tRBcbdIkoqM4=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/wdvxdr1123/ZeroBot v1.6.8 h1:jdFhd6Bk0JBIKPpKhHnkACtjnIf4co6Hdw3U16e4Gi0=
github.com/wdvxdr1123/ZeroBot v1.6.8/go.mod h1:T5kD5vLi/YxL/fyDOCOaawi96LRBdJjcXh2CIjDyFfg=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
Expand All @@ -58,16 +38,12 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
Expand Down
24 changes: 12 additions & 12 deletions title.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"image"

"github.com/FloatTech/gg"
"github.com/FloatTech/zbputils/img"
"github.com/FloatTech/imgfactory"
)

// DrawTitle 绘制标题
Expand Down Expand Up @@ -48,22 +48,22 @@ func (t *Title) DrawTitle() (imgs image.Image, err error) {
canvas.DrawStringAnchored(t.LeftSubtitle, 3+(220-(fontsize1+fontsize2)*72/96)*0.33+stringwight/2+t.OffsetX, 30+40+(220-(fontsize1+fontsize2)*72/96)*0.66+fontsize1*72/96+fontsize2*72/96*0.5+t.OffsetY, 0.5, 0.5)

// 加载icon并绘制
var icon *img.Factory
icon, err = img.LoadFirstFrame(t.ImagePath, 220, 220)
var icon *imgfactory.Factory
icon, err = imgfactory.LoadFirstFrame(t.ImagePath, 220, 220)
if err != nil {
return
}
canvas.DrawImage(icon.Im, int(DefaultWidth)-icon.W, 40+30)
canvas.DrawImage(icon.Image(), int(DefaultWidth)-icon.W(), 40+30)
// 加载size为72的字体
fontsize1 = 72 + t.TextFontOffsetPoint
err = canvas.LoadFontFace(t.TextFont, fontsize1)
if err != nil {
return
}
stringwight, _ = canvas.MeasureString(t.RightTitle)
canvas.DrawStringAnchored(t.RightTitle, DefaultWidth-25-float64(icon.W)-stringwight/2+t.OffsetX, 30+40+(220-fontsize1*72/96*2)*0.33+fontsize1*72/96*0.5+t.OffsetY, 0.5, 0.5)
canvas.DrawStringAnchored(t.RightTitle, DefaultWidth-25-float64(icon.W())-stringwight/2+t.OffsetX, 30+40+(220-fontsize1*72/96*2)*0.33+fontsize1*72/96*0.5+t.OffsetY, 0.5, 0.5)
stringwight, _ = canvas.MeasureString(t.RightSubtitle)
canvas.DrawStringAnchored(t.RightSubtitle, DefaultWidth-25-float64(icon.W)-stringwight/2+t.OffsetX, 30+40+(220-fontsize1*72/96*2)*0.66+fontsize1*72/96*1.5+t.OffsetY, 0.5, 0.5)
canvas.DrawStringAnchored(t.RightSubtitle, DefaultWidth-25-float64(icon.W())-stringwight/2+t.OffsetX, 30+40+(220-fontsize1*72/96*2)*0.66+fontsize1*72/96*1.5+t.OffsetY, 0.5, 0.5)

imgs = canvas.Image()
return
Expand All @@ -83,12 +83,12 @@ func (t *Title) DrawTitleWithText(info []string) (imgs image.Image, err error) {
canvas.Clear()

// 加载icon
var icon *img.Factory
icon, err = img.LoadFirstFrame(t.ImagePath, 512, 512)
var icon *imgfactory.Factory
icon, err = imgfactory.LoadFirstFrame(t.ImagePath, 512, 512)
if err != nil {
return
}
canvas.DrawImage(icon.Im, DefaultWidth-icon.W, imgh-icon.H)
canvas.DrawImage(icon.Image(), DefaultWidth-icon.W(), imgh-icon.H())

// 加载size为108的字体
fontsize1, fontsize2 := 108.0+t.TitleFontOffsetPoint, 54.0+t.TextFontOffsetPoint
Expand Down Expand Up @@ -154,10 +154,10 @@ func (t *Title) DrawCard() (imgs image.Image, err error) {
recw, rech := 384.0, 256.0
canvas := gg.NewContext(int(recw), int(rech))
// 绘制图片
var banner *img.Factory
banner, err = img.LoadFirstFrame(t.ImagePath, int(recw)*2, int(rech)*2)
var banner *imgfactory.Factory
banner, err = imgfactory.LoadFirstFrame(t.ImagePath, int(recw)*2, int(rech)*2)
if err == nil {
canvas.DrawImage(img.Size(banner.Im, int(recw), int(rech)).Im, 0, 0)
canvas.DrawImage(imgfactory.Size(banner.Image(), int(recw), int(rech)).Image(), 0, 0)
} else {
canvas.DrawRectangle(0, 0, recw, rech)
canvas.SetRGB255(RandJPColor())
Expand Down

0 comments on commit 82492b7

Please sign in to comment.