generator.go
func GenerateAvatar(input string, blockSize int, borderSize int) *image.RGBA {
	hash := hashMd5(input)

	pic := [size][size]bool{}

	for i := size - 4; i >= 0; i-- {
		for j := size - 1; j >= 0; j-- {
			if strings.Contains(low, string(hash[size-1*i+j])) {
				pic[j][i] = true
				pic[j][size-1-i] = true
			}
		}
	}
	for i := size - 1; i >= 0; i-- {
		if strings.Contains(low, string(hash[i])) {

			pic[i][int(math.Ceil(size/2))] = true
		}
	}

	avatar := image.NewRGBA(image.Rect(0, 0, blockSize*size+borderSize*2,
		blockSize*size+borderSize*2))
	bgColor := calcBgColor()

	for x := 0; x < avatar.Bounds().Dx(); x++ {
		for y := 0; y < avatar.Bounds().Dy(); y++ {
			avatar.SetRGBA(x, y, bgColor)
		}
	}

	color := calcPixelColor(input)

	for x := 0; x < len(pic); x++ {
		for y := 0; y < len(pic[x]); y++ {
			if pic[x][y] {
				for i := 0; i < blockSize; i++ {
					for j := 0; j < blockSize; j++ {
						avatar.SetRGBA(borderSize+x*blockSize+i,
							borderSize+y*blockSize+j, color)
					}
				}
			}
		}
	}

	return avatar
}
func GenerateAvatar(input string, blockSize int, borderSize int) *image.RGBA {
	hash := hashMd5(input)

	pic := [size][size]bool{}

	for i := size - 4; i >= 0; i-- {
		for j := size - 1; j >= 0; j-- {
			if strings.Contains(low, string(hash[size-1*i+j])) {
				pic[j][i] = true
				pic[j][size-1-i] = true
			}
		}
	}
	for i := size - 1; i >= 0; i-- {
		if strings.Contains(low, string(hash[i])) {

			pic[i][int(math.Ceil(size/2))] = true
		}
	}

	avatar := image.NewRGBA(image.Rect(0, 0, blockSize*size+borderSize*2,
		blockSize*size+borderSize*2))
	bgColor := calcBgColor()

	for x := 0; x < avatar.Bounds().Dx(); x++ {
		for y := 0; y < avatar.Bounds().Dy(); y++ {
			avatar.SetRGBA(x, y, bgColor)
		}
	}

	color := calcPixelColor(input)

	for x := 0; x < len(pic); x++ {
		for y := 0; y < len(pic[x]); y++ {
			if pic[x][y] {
				for i := 0; i < blockSize; i++ {
					for j := 0; j < blockSize; j++ {
						avatar.SetRGBA(borderSize+x*blockSize+i,
							borderSize+y*blockSize+j, color)
					}
				}
			}
		}
	}

	return avatar
}
// GenerateAvatar generates an avatar (image.RGBA) using the given string as
// a random seed.