A simple refactor of generateImage() rearranging method calls in for loops.
This commit is contained in:
parent
ffbc79ce4b
commit
504a8d137f
@ -43,8 +43,8 @@ func (c *DwellingCaptcha) generateImage(style string) *image.Image {
|
|||||||
for i := 0; i < 16; i++ {
|
for i := 0; i < 16; i++ {
|
||||||
x0, _ := rand.Int(rand.Reader, big.NewInt(int64(ctx.Height())))
|
x0, _ := rand.Int(rand.Reader, big.NewInt(int64(ctx.Height())))
|
||||||
x1, _ := 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)))
|
r, _ := rand.Int(rand.Reader, big.NewInt(int64(4)))
|
||||||
|
ctx.SetLineWidth(2)
|
||||||
ctx.DrawPoint(float64(x0.Int64()), float64(x1.Int64()), float64(r.Int64()))
|
ctx.DrawPoint(float64(x0.Int64()), float64(x1.Int64()), float64(r.Int64()))
|
||||||
ctx.DrawLine(float64(x0.Int64()), 0, float64(ctx.Height()), float64(x1.Int64()))
|
ctx.DrawLine(float64(x0.Int64()), 0, float64(ctx.Height()), float64(x1.Int64()))
|
||||||
ctx.Stroke()
|
ctx.Stroke()
|
||||||
@ -53,10 +53,10 @@ func (c *DwellingCaptcha) generateImage(style string) *image.Image {
|
|||||||
for i := 0; i < 16; i++ {
|
for i := 0; i < 16; i++ {
|
||||||
x0, _ := rand.Int(rand.Reader, big.NewInt(int64(ctx.Height())))
|
x0, _ := rand.Int(rand.Reader, big.NewInt(int64(ctx.Height())))
|
||||||
x1, _ := 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)))
|
r, _ := rand.Int(rand.Reader, big.NewInt(int64(4)))
|
||||||
|
ctx.SetLineWidth(2)
|
||||||
ctx.DrawPoint(float64(x0.Int64()), float64(x1.Int64()), float64(r.Int64()))
|
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()
|
ctx.Stroke()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user