commit e2688e6494aaa5e14cb4673a6abacd85157ce727
parent 639b6a27245658ef78837e01ff877daf39a809e6
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Sat, 27 May 2023 23:08:31 -0700
deindent
Diffstat:
| M | pkg/captcha/image.go | | | 107 | ++++++++++++++++++++++++++++++++++++++----------------------------------------- |
1 file changed, 52 insertions(+), 55 deletions(-)
diff --git a/pkg/captcha/image.go b/pkg/captcha/image.go
@@ -675,69 +675,66 @@ func (m *Image) renderFakePath(points []Point) {
d := m.CubicDelta
gradColors := m.getGradientColors(len(points))
+ // Draw the whole line
m.withState(func() {
+ m.c.SetLineWidth(1)
+ for i := 1; i < len(points); i++ {
+ prev := points[i-1]
+ pt := points[i]
+ grad := getGradient(prev, pt, gradColors, i)
+ m.c.SetStrokeStyle(grad)
+ m.strokeCubicLine(prev, pt, -d)
+ }
+ })
- // Draw the whole line
- m.withState(func() {
- m.c.SetLineWidth(1)
- for i := 1; i < len(points); i++ {
- prev := points[i-1]
- pt := points[i]
- grad := getGradient(prev, pt, gradColors, i)
- m.c.SetStrokeStyle(grad)
- m.strokeCubicLine(prev, pt, -d)
- }
- })
-
- // Semi transparent black line on top of the line
- m.withState(func() {
- m.c.SetLineWidth(4)
- m.c.SetColor(color.RGBA{R: 15, G: 15, B: 15, A: 100})
- for i := 1; i < len(points); i++ {
- prev := points[i-1]
- pt := points[i]
- m.strokeCubicLine(prev, pt, -d)
- m.strokeCubicLine(pt, prev, d)
- }
- })
+ // Semi transparent black line on top of the line
+ m.withState(func() {
+ m.c.SetLineWidth(4)
+ m.c.SetColor(color.RGBA{R: 15, G: 15, B: 15, A: 100})
+ for i := 1; i < len(points); i++ {
+ prev := points[i-1]
+ pt := points[i]
+ m.strokeCubicLine(prev, pt, -d)
+ m.strokeCubicLine(pt, prev, d)
+ }
+ })
- // Draw the whole line again with dashes
- m.withState(func() {
- m.c.SetDash(5, 3)
- for i := 1; i < len(points); i++ {
- prev := points[i-1]
- pt := points[i]
- grad := getGradient(prev, pt, gradColors, i)
- m.c.SetStrokeStyle(grad)
+ // Draw the whole line again with dashes
+ m.withState(func() {
+ m.c.SetDash(5, 3)
+ for i := 1; i < len(points); i++ {
+ prev := points[i-1]
+ pt := points[i]
+ grad := getGradient(prev, pt, gradColors, i)
+ m.c.SetStrokeStyle(grad)
- m.withState(func() {
- m.c.SetLineWidth(4)
- m.c.SetColor(color.RGBA{R: 15, G: 15, B: 15, A: 255})
- m.strokeCubicLine(prev, pt, -d)
- })
+ m.withState(func() {
+ m.c.SetLineWidth(4)
+ m.c.SetColor(color.RGBA{R: 15, G: 15, B: 15, A: 255})
+ m.strokeCubicLine(prev, pt, -d)
+ })
- m.withState(func() {
- m.c.SetLineWidth(1.5)
- m.strokeCubicLine(prev, pt, -d)
- })
- }
- })
+ m.withState(func() {
+ m.c.SetLineWidth(1.5)
+ m.strokeCubicLine(prev, pt, -d)
+ })
+ }
+ })
- // Draw line edges with longer dashes
- m.withState(func() {
- m.c.SetDash(30, 200)
- m.c.SetLineWidth(1.5)
- for i := 1; i < len(points); i++ {
- prev := points[i-1]
- pt := points[i]
+ // Draw line edges with longer dashes
+ m.withState(func() {
+ m.c.SetDash(30, 200)
+ m.c.SetLineWidth(1.5)
+ for i := 1; i < len(points); i++ {
+ prev := points[i-1]
+ pt := points[i]
- grad := getGradient(prev, pt, gradColors, i)
- m.c.SetStrokeStyle(grad)
+ grad := getGradient(prev, pt, gradColors, i)
+ m.c.SetStrokeStyle(grad)
- m.strokeCubicLine(prev, pt, -d)
- m.strokeCubicLine(pt, prev, d)
- }
- })
+ m.strokeCubicLine(prev, pt, -d)
+ m.strokeCubicLine(pt, prev, d)
+ }
})
}