From 504a8d137f919ab0d71720b17c5a6b530b47cead Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 27 Jun 2022 01:25:28 +0400 Subject: [PATCH] A simple refactor of generateImage() rearranging method calls in for loops. --- internal/captcha/dwelling_captcha.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/captcha/dwelling_captcha.go b/internal/captcha/dwelling_captcha.go index dc209e8..97af92c 100644 --- a/internal/captcha/dwelling_captcha.go +++ b/internal/captcha/dwelling_captcha.go @@ -43,8 +43,8 @@ func (c *DwellingCaptcha) generateImage(style string) *image.Image { for i := 0; i < 16; i++ { x0, _ := rand.Int(rand.Reader, big.NewInt(int64(ctx.Height()))) x1, _ := rand.Int(rand.Reader, big.NewInt(int64(ctx.Height()))) - ctx.SetLineWidth(2) r, _ := rand.Int(rand.Reader, big.NewInt(int64(4))) + ctx.SetLineWidth(2) ctx.DrawPoint(float64(x0.Int64()), float64(x1.Int64()), float64(r.Int64())) ctx.DrawLine(float64(x0.Int64()), 0, float64(ctx.Height()), float64(x1.Int64())) ctx.Stroke() @@ -53,10 +53,10 @@ func (c *DwellingCaptcha) generateImage(style string) *image.Image { for i := 0; i < 16; i++ { x0, _ := rand.Int(rand.Reader, big.NewInt(int64(ctx.Height()))) x1, _ := rand.Int(rand.Reader, big.NewInt(int64(ctx.Height()))) - ctx.SetLineWidth(2) - ctx.DrawLine(0, float64(x0.Int64()), float64(x1.Int64()), float64(ctx.Height())) r, _ := rand.Int(rand.Reader, big.NewInt(int64(4))) + ctx.SetLineWidth(2) ctx.DrawPoint(float64(x0.Int64()), float64(x1.Int64()), float64(r.Int64())) + ctx.DrawLine(0, float64(x0.Int64()), float64(x1.Int64()), float64(ctx.Height())) ctx.Stroke() }