2021-02-02 04:49:09 +03:00
|
|
|
# Golang port of DiceBear Avatars
|
2021-02-02 03:41:25 +03:00
|
|
|
|
2021-02-02 04:49:09 +03:00
|
|
|
which in turn were inspired by 8biticon avatars
|
2021-02-02 03:41:25 +03:00
|
|
|
|
2021-02-02 04:29:42 +03:00
|
|
|
![Example images](mosaic.png)
|
2021-02-02 04:43:59 +03:00
|
|
|
|
2021-02-02 04:49:09 +03:00
|
|
|
## Usage
|
2021-02-02 04:43:59 +03:00
|
|
|
|
2021-02-02 04:49:09 +03:00
|
|
|
import `codeberg.org/Codeberg/avatars` & use `string svg = avatars.MakeAvatar(seed)`
|
2021-02-02 04:43:59 +03:00
|
|
|
|
|
|
|
## Build & Use Example
|
2021-02-02 03:41:25 +03:00
|
|
|
|
|
|
|
```shell
|
2021-02-02 04:43:59 +03:00
|
|
|
# will build the binary
|
|
|
|
go build -o avatars example/main.go
|
2021-02-02 04:46:42 +03:00
|
|
|
# Create a random avatar and write it to /tmp/avatar.svg. Note that for the same seed string always the same image will be generated.
|
2021-02-02 04:43:59 +03:00
|
|
|
./avatars my-special-seed-string > /tmp/avatar.svg
|
2021-02-02 04:43:25 +03:00
|
|
|
# Open SVG file with image viewer
|
2021-02-02 04:29:42 +03:00
|
|
|
eog /tmp/avatar.svg
|
2021-02-02 03:41:25 +03:00
|
|
|
```
|
|
|
|
|
2021-02-02 04:29:42 +03:00
|
|
|
## Create mosaic with example images using rsvg and imagemagick montage
|
2021-02-02 03:41:25 +03:00
|
|
|
|
2021-02-02 04:29:42 +03:00
|
|
|
```shell
|
2021-02-02 04:49:09 +03:00
|
|
|
go build -o avatars example/main.go
|
2021-02-02 04:29:42 +03:00
|
|
|
for i in {1..40} ; do
|
2021-02-02 04:49:09 +03:00
|
|
|
./avatars my-special-seed-string_$i > /tmp/avatar_$i.svg
|
2021-02-02 04:29:42 +03:00
|
|
|
rsvg-convert /tmp/avatar_$i.svg -z 10 -o /tmp/avatar_$i.png
|
|
|
|
done
|
|
|
|
montage -tile 10x4 /tmp/avatar_*.png /tmp/mosaic.png
|
|
|
|
eog /tmp/mosaic.png
|
|
|
|
```
|