This package provides a simple way to generate unique, symmetric identicons based on an input string (e.g., an email address or username). It uses an MD5 hash to create a deterministic pattern and color scheme, then mirrors the design for a visually appealing avatar.
QuantumNomad42
EchoFrost7
NebulaTide19
ZephyrPulse88
EmberNexus23
Shaped fg pixels
Shaped fg pixels w/transparency
Shaped fg & bg pixels
Shaped fg & bg pixels, w/transparency
To use this package in your Go project, install it via:
go get github.com/MuhammadSaim/goavatar
Then, import it in your Go code:
import "github.com/MuhammadSaim/goavatar"
See the example folder for a program that creates the identicons found in the arts directory.
func Make(input, ...optFunc) image.Image
input
: A string used to generate a unique identicon (e.g., email, username)....optFunc
: Functional options to override the default values.image.Image
: Function returns animage.Image
, allowing the caller to handle image processing, encoding, and storage as needed.
// WithSize sets the size of the avatar.
// It is always square and has a minimum size of 64x64
func WithSize(s int) optFunc
// WithGridSize sets the grid size of the avatar.
func WithGridSize(g int) optFunc
// WithBgColor sets the background color of the avatar.
func WithBgColor(r, g, b, a uint8) optFunc
// WithFgColor sets the foreground color of the avatar.
func WithFgColor(r, g, b, a uint8) optFunc
// WithFgShape sets the shape of the foreground pixels.
func WithFgShape(s [][]int) optFunc
// WithBgShape sets the shape of the background pixels.
func WithBgShape(s [][]int) optFunc
// WithTransparency sets the option to have the background show
// through any negative space in shaped foreground pixels.
func WithTransparency() optFunc
This project is open-source under the MIT License.
Contributions are welcome! Feel free to open a pull request or create an issue.