-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.go
44 lines (39 loc) · 872 Bytes
/
template.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package captcha
import (
"math/rand"
"time"
)
// Template is an instantiation that used for defining some templates for captcha image.
type Template struct {
Background string // Background color of captcha image
Color string // Color of the captcha word
}
var Templates = []Template{
{
Background: "#ffffff",
Color: "#8aaae5",
}, {
Background: "#fBf8Be",
Color: "#234e70",
}, {
Background: "#000000",
Color: "#f3ca20",
}, {
Background: "d9a5b3",
Color: "#1868ae",
}, {
Background: "fff1e1",
Color: "1d3c45",
}, {
Background: "#ced7d8",
Color: "#f47a60",
}, {
Background: "#ffffff",
Color: "#cc9999",
},
}
// RandTemplate generates a random template from the template array.
func RandTemplate() Template {
rand.Seed(time.Now().UnixNano())
return Templates[rand.Intn(len(Templates))]
}