mirror of
https://github.com/pcvolkmer/idicon.git
synced 2025-04-19 16:46:50 +00:00
Preventing index out of range error if increasing block size
This commit is contained in:
parent
80d97f6307
commit
53a95b1d50
@ -10,7 +10,7 @@ HTTP `GET` is used to request an identicon image.
|
||||
curl http://localhost:8000/avatar/23463b99b62a72f26ed677cc556c44e8?s=100&c=v2
|
||||
....
|
||||
|
||||
Instead of requesting identicons for MD5 hashes of usernames or mail addresses, it is possible to use plain username and mail address. The will result in the same generated identicon.
|
||||
Instead of requesting identicons for MD5 hashes of usernames or mail addresses, it is possible to use plain username and mail address. This will result in the same generated identicon.
|
||||
|
||||
Use request query parameter `s` to request images with specified size. Default value is 80px. The size is limited to a maximum value of 512px.
|
||||
|
||||
|
@ -40,7 +40,6 @@ func genGhIcon(id string, size int, f func([16]byte) color.RGBA) *image.NRGBA {
|
||||
if size > 512 {
|
||||
size = 512
|
||||
}
|
||||
|
||||
blocks := 5
|
||||
|
||||
hash := hashBytes(id)
|
||||
@ -52,7 +51,7 @@ func genGhIcon(id string, size int, f func([16]byte) color.RGBA) *image.NRGBA {
|
||||
ni := x + blocks*(blocks-y-1)
|
||||
if x+blocks*y > 2*blocks {
|
||||
di := (x + blocks*y) - 2*blocks
|
||||
data[di] = nibbles[ni]%2 == 0
|
||||
data[di] = nibbles[ni%32]%2 == 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user