Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiang-Red committed Jan 12, 2023
1 parent 732aae3 commit 2de4cb0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions shadow.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ func DrawRoundShadowedRectangle(canvas *gg.Context, x, y, w, h, r, sr, sigma flo

// DrawShadowedRectangle 绘制阴影
func DrawShadowedRectangle(canvas *gg.Context, x, y, w, h, r, sigma float64, ox, oy int, shadowcolor color.Color) {
one := gg.NewContext(canvas.W(), canvas.H())
one := gg.NewContextForImage(Transparency(canvas.Image(), 0))
one.DrawRoundedRectangle(x, y, w, h, r)
one.SetColor(shadowcolor)
one.Fill()
canvas.DrawImage(imaging.Blur(one.Image(), sigma), int(x)+ox, int(y)+oy)
canvas.DrawImage(imaging.Blur(one.Image(), sigma), ox, oy)
}

// DrawShadowedString 绘制带阴影的文字
Expand All @@ -33,7 +33,7 @@ func DrawShadowedString(canvas *gg.Context, s, fontfile string, x, y, point, sig
}
one.SetColor(shadowcolor)
one.DrawString(s, x, y)
canvas.DrawImage(imaging.Blur(one.Image(), sigma), int(x)+ox, int(y)+oy)
canvas.DrawImage(imaging.Blur(one.Image(), sigma), ox, oy)
err = canvas.LoadFontFace(fontfile, point)
if err != nil {
return
Expand All @@ -52,7 +52,7 @@ func DrawShadowedStringAnchored(canvas *gg.Context, s, fontfile string, x, y, po
}
one.SetColor(shadowcolor)
one.DrawStringAnchored(s, x, y, ax, ay)
canvas.DrawImage(imaging.Blur(one.Image(), sigma), int(x)+ox, int(y)+oy)
canvas.DrawImage(imaging.Blur(one.Image(), sigma), ox, oy)
err = canvas.LoadFontFace(fontfile, point)
if err != nil {
return
Expand Down

0 comments on commit 2de4cb0

Please sign in to comment.