From 9ce6476378bbfd491cda0c85bf8bcf29bd44a32e Mon Sep 17 00:00:00 2001 From: solar Date: Thu, 6 Oct 2022 23:01:14 +0800 Subject: [PATCH] fixed minX maxY --- canvas.go | 7 +++---- captcha_test.go | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/canvas.go b/canvas.go index 102d264..bed7cd4 100644 --- a/canvas.go +++ b/canvas.go @@ -335,21 +335,20 @@ func (c *Canvas) calcImageSpace(pa *Palette) *AreaPoint { } func (c *Canvas) randomFontPosition(fontSize int) Point { - minX := fontSize + minX := 0 minY := fontSize - maxX := c.Width - fontSize - maxY := c.Height - fontSize + maxY := c.Height x := randomInt(minX, maxX) y := randomInt(minY, maxY) return Point{x, y} - } //randomInt 返回随机数 [min,max) func randomInt(min, max int) int { + // rand.Seed(time.Now().UnixNano()) if min >= max || max == 0 { return max } diff --git a/captcha_test.go b/captcha_test.go index 429b97e..f25f66f 100644 --- a/captcha_test.go +++ b/captcha_test.go @@ -29,6 +29,7 @@ func TestGenGenBehaviorCaptcha(t *testing.T) { cpt.SetBackgroundColor(color.RGBA{R: uint8(20), G: uint8(8), B: uint8(100), A: uint8(255)}) cpt.Config.Style = CaptchaStyle_Behavior cpt.Config.MaxRotate = 20 + cpt.Config.FontSize = 36 t.Logf("cpt.Config: %+v ", cpt.Config)