commit 943155d8ee18ee5437b83c653b9550e6f5664196
parent 7cab8747f50938186596725c4cdb727dd4ae0dd0
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Sun, 28 May 2023 00:08:14 -0700
cleanup
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/pkg/captcha/image.go b/pkg/captcha/image.go
@@ -469,6 +469,8 @@ func (m *Image) withState(clb func()) {
clb()
}
+var blackClr = color.RGBA{R: 15, G: 15, B: 15, A: 255}
+
// This is a hack because github.com/golang/freetype is not thread safe and will crash the program.
// So we can only render 1 captcha at the time.
// https://github.com/golang/freetype/issues/65
@@ -616,7 +618,7 @@ func (m *Image) renderPath(points []Point) {
m.withState(func() {
m.c.SetLineWidth(4)
- m.c.SetColor(color.RGBA{R: 15, G: 15, B: 15, A: 255})
+ m.c.SetColor(blackClr)
m.strokeCubicLine(prev, pt, d)
})
@@ -643,7 +645,7 @@ func (m *Image) renderPath(points []Point) {
if i == len(points)-1 {
m.withState(func() {
m.c.SetLineWidth(4)
- m.c.SetColor(color.RGBA{R: 15, G: 15, B: 15, A: 255})
+ m.c.SetColor(blackClr)
m.strokeCubicLine(pt, prev, -d)
})
@@ -704,7 +706,7 @@ func (m *Image) renderFakePath(points []Point) {
m.withState(func() {
m.c.SetLineWidth(4)
- m.c.SetColor(color.RGBA{R: 15, G: 15, B: 15, A: 255})
+ m.c.SetColor(blackClr)
m.strokeCubicLine(prev, pt, -d)
})
@@ -738,7 +740,7 @@ func (m *Image) renderBackground() {
//grad.AddColorStop(0, color.RGBA{10, 10, 10, 255})
//grad.AddColorStop(1, color.RGBA{50, 50, 50, 255})
//m.c.SetFillStyle(grad)
- m.c.SetColor(color.RGBA{R: 15, G: 15, B: 15, A: 255})
+ m.c.SetColor(blackClr)
m.c.DrawRectangle(0, 0, float64(m.imageWidth), float64(m.imageHeight))
m.c.Fill()
})
@@ -746,7 +748,7 @@ func (m *Image) renderBackground() {
func (m *Image) renderBorder() {
m.withState(func() {
- m.c.SetColor(color.RGBA{R: 15, G: 15, B: 15, A: 255})
+ m.c.SetColor(blackClr)
m.c.DrawRectangle(0, 0, float64(m.imageWidth)-0.5, float64(m.imageHeight)-0.5)
m.c.Stroke()
})