commit 2d53acaea0a640a616f4212cc9152e476d5f1b48
parent 88703b52e3c3dc961fa3e9fe59744be659be168f
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Sat, 27 May 2023 22:45:31 -0700
cleanup
Diffstat:
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/pkg/captcha/image.go b/pkg/captcha/image.go
@@ -590,14 +590,19 @@ func getGradient(p1, p2 Point, gradColors []color.RGBA, i int) gg.Gradient {
return grad
}
-func (m *Image) renderPath(points []Point) {
- d := m.CubicDelta
-
- gradColors := make([]color.RGBA, len(points)*2)
- for i := 0; i < len(points)*2; i += 2 {
+func (m *Image) getGradientColors(nbPoints int) []color.RGBA {
+ gradColors := make([]color.RGBA, nbPoints*2)
+ for i := 0; i < nbPoints*2; i += 2 {
gradColors[i] = m.getLineColor()
gradColors[i+1] = m.getLineColor()
}
+ return gradColors
+}
+
+func (m *Image) renderPath(points []Point) {
+ d := m.CubicDelta
+
+ gradColors := m.getGradientColors(len(points))
m.withState(func() {
// Draw the whole line
@@ -671,18 +676,13 @@ func (m *Image) renderPath(points []Point) {
}
func (m *Image) renderFakePath(points []Point) {
- d := m.CubicDelta
-
- gradColors := make([]color.RGBA, len(points)*2)
- for i := 0; i < len(points)*2; i += 2 {
- gradColors[i] = m.getLineColor()
- gradColors[i+1] = m.getLineColor()
- }
-
if m.renderHelpImg {
return
}
+ d := m.CubicDelta
+ gradColors := m.getGradientColors(len(points))
+
m.withState(func() {
// Draw the whole line