Update, new mentions, fixed captcha icons Y-pos
This commit is contained in:
@ -10,7 +10,6 @@ import (
|
||||
"log"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fogleman/gg"
|
||||
)
|
||||
@ -55,13 +54,12 @@ func initImage() *gg.Context {
|
||||
// а правильный вариант возвращается вместе с итоговой картинкой
|
||||
func GenCaptcha() Captcha {
|
||||
dc := initImage()
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
rand.Shuffle(len(Logos), func(i, j int) { Logos[i], Logos[j] = Logos[j], Logos[i] }) // Перемешиваем логотипы
|
||||
rand.Shuffle(len(XPositions), func(i, j int) { XPositions[i], XPositions[j] = XPositions[j], XPositions[i] }) // И позиции
|
||||
correct_answer := 0
|
||||
for i, logo := range Logos {
|
||||
x := XPositions[i]
|
||||
y := rand.Intn(ImageHeight - logo.Image.Bounds().Dy() - 30)
|
||||
y := rand.Intn(ImageHeight - logo.Image.Bounds().Dy() - 70)
|
||||
dc.DrawImage(logo.Image, x, y)
|
||||
if logo.IsCorrect {
|
||||
correct_answer = i + 1
|
||||
|
Reference in New Issue
Block a user