modulepackage
0.0.0-20240904200805-3803a50c51e4
Repository: https://github.com/go-mods/avatar.git
Documentation: pkg.go.dev
# README
avatar
Avatar is a Go package that generates avatar from name.
Circle avatar
Square avatar
Custom avatar
Color palette from initial
Avatar server
Use docker to run the server:
docker build -t avatar-server .
docker run -t --rm -v ./assets:/avatar/assets -p 8080:8080 -d --name avatar-server avatar-server
or use docker-compose:
docker-compose build
docker-compose up -d
Generate an avatar
http://localhost:8080/api?name=John%20Doe
http://localhost:8080/api?name=John%20Doe&shape=square&width=200&height=200&backgroundColor=red&fontColor=white&fontFamily=Caprasimo&fontWeight=400&borderWidth=10&borderColor=blue&borderDash=10,10&borderRadius=50&padding=5
Options (query params) to use to customize the avatar initial
query parameter | type |
---|---|
name | string |
separator | string |
sensitive | string |
lowercase | boolean |
uppercase | boolean |
camelcase | boolean |
length | number |
wordLength | boolean |
Options (query params) to use to customize the avatar
query parameter | type |
---|---|
width | number |
height | number |
backgroundColor | string |
fontFamily | string |
fontWeight | string |
fontSize | number |
fontColor | string |
shape | string (circle, square) |
borderDash | string (css border dash) |
borderWidth | number |
borderRadius | number |
borderColor | string |
padding | number |
randomFontColor | boolean |
randomBorderColor | boolean |
# Functions
BackgroundColorFunc sets the background color generator function.
BorderColorFunc sets the border color generator function.
GetSVG returns the svg of a name.
NewColorGenerator returns a new colorGenerator.
TextColorFunc sets the text color generator function.
WithBackgroundColor sets the background color of the svg.
WithBackgroundColorFunc sets the background color function.
WithBorderColor sets the border color.
WithBorderColorFunc sets the border color function of the svg.
WithBorderDash sets the border style.
WithBorderRadius sets the border radius.
WithBorderWidth sets the border width.
WithFont sets the font of the svg.
WithFontColor sets the font color of the text.
WithFontColorFunc sets the font color function.
WithFontDir sets the directory for storing font files.
WithFontSize sets the font size of the text.
WithHeight sets the height of the svg.
WithPadding sets the padding.
WithRandomBackgroundColor sets the svg to be random background color.
WithRandomBorderColor sets the svg to be random border color.
WithRandomColor sets the svg to use random colors.
WithRandomFontColor sets the svg to be random font color.
WithShape sets the shape of the svg.
WithWidth sets the width of the svg.
# Type aliases
ColorFunc is function used to generate a color.
ColorOption is a function to set the colorGenerator options.
GeneratorOption is a function to set the avatarGenerator options.