@@ -4,7 +4,6 @@ package wife
44import (
55 "bytes"
66 "image"
7- "image/color"
87 "math/rand"
98 "strings"
109 "time"
@@ -15,7 +14,6 @@ import (
1514 zero "github.com/wdvxdr1123/ZeroBot"
1615 "github.com/wdvxdr1123/ZeroBot/message"
1716
18- zbmath "github.com/FloatTech/floatbox/math"
1917 "github.com/FloatTech/imgfactory"
2018)
2119
@@ -134,24 +132,8 @@ func init() {
134132 })
135133}
136134
137- // 马赛克生成
135+ // 高斯模糊生成
138136func mosaic (dst * imgfactory.Factory , level int ) ([]byte , error ) {
139- b := dst .Image ().Bounds ()
140- p := imgfactory .NewFactoryBG (dst .W (), dst .H (), color.NRGBA {255 , 255 , 255 , 255 })
141- markSize := zbmath .Max (b .Max .X , b .Max .Y ) * sizeList [level ] / 200
142-
143- for yOfMarknum := 0 ; yOfMarknum <= zbmath .Ceil (b .Max .Y , markSize ); yOfMarknum ++ {
144- for xOfMarknum := 0 ; xOfMarknum <= zbmath .Ceil (b .Max .X , markSize ); xOfMarknum ++ {
145- a := dst .Image ().At (xOfMarknum * markSize + markSize / 2 , yOfMarknum * markSize + markSize / 2 )
146- cc := color .NRGBAModel .Convert (a ).(color.NRGBA )
147- for y := 0 ; y < markSize ; y ++ {
148- for x := 0 ; x < markSize ; x ++ {
149- xOfPic := xOfMarknum * markSize + x
150- yOfPic := yOfMarknum * markSize + y
151- p .Image ().Set (xOfPic , yOfPic , cc )
152- }
153- }
154- }
155- }
156- return imgfactory .ToBytes (p .Blur (3 ).Image ())
137+ blurRadius := float64 (sizeList [level ] * 3 )
138+ return imgfactory .ToBytes (dst .Blur (blurRadius ).Image ())
157139}
0 commit comments