Skip to content

Commit 9ce6476

Browse files
committed
fixed minX maxY
1 parent 46bc04e commit 9ce6476

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

canvas.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -335,21 +335,20 @@ func (c *Canvas) calcImageSpace(pa *Palette) *AreaPoint {
335335
}
336336

337337
func (c *Canvas) randomFontPosition(fontSize int) Point {
338-
minX := fontSize
338+
minX := 0
339339
minY := fontSize
340-
341340
maxX := c.Width - fontSize
342-
maxY := c.Height - fontSize
341+
maxY := c.Height
343342

344343
x := randomInt(minX, maxX)
345344
y := randomInt(minY, maxY)
346345

347346
return Point{x, y}
348-
349347
}
350348

351349
//randomInt 返回随机数 [min,max)
352350
func randomInt(min, max int) int {
351+
// rand.Seed(time.Now().UnixNano())
353352
if min >= max || max == 0 {
354353
return max
355354
}

captcha_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func TestGenGenBehaviorCaptcha(t *testing.T) {
2929
cpt.SetBackgroundColor(color.RGBA{R: uint8(20), G: uint8(8), B: uint8(100), A: uint8(255)})
3030
cpt.Config.Style = CaptchaStyle_Behavior
3131
cpt.Config.MaxRotate = 20
32+
cpt.Config.FontSize = 36
3233

3334
t.Logf("cpt.Config: %+v ", cpt.Config)
3435

0 commit comments

Comments
 (0)