Skip to content

Commit

Permalink
fixed minX maxY
Browse files Browse the repository at this point in the history
  • Loading branch information
feiin committed Oct 6, 2022
1 parent 46bc04e commit 9ce6476
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions captcha_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 9ce6476

Please sign in to comment.