Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/mcbattirola/avatargen

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/mcbattirola/avatargen

  • v0.0.0-20201215234306-5459476bc021
  • Source
  • Go
  • Socket score

Version published
Created
Source

Avatargen

avatar

This is a simple project to generate unique 300x300 avatars for any input string, havily inspired by loweisz's generate-avatar.

How to use

Get the package:

go get github.com/mcbattirola/avatargen

Call the method Generate with a string as argument:

import "github.com/mcbattirola/avatargen"


svg := avatargen.Generate("mystring")
fmt.Println(svg) 

/* output:
<svg width="300" height="300" viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg"><rect id="bg" width="300" height="300" fill="rgb(22,147,25)" /><path d="m 150 597 Q 282 18 -297 150 Q 282 282 150 -297 Q 18 282 597 150 Q 18 18 150 597 z" fill="rgb(232,249,208)" /><path d="m 150 368 Q 203 97 -68 150 Q 203 203 150 -68 Q 97 203 368 150 Q 97 97 150 368 z" fill="rgb(208,249,232)" /><path d="m 150 265 Q 135 165 35 150 Q 135 135 150 35 Q 165 135 265 150 Q 165 165 150 265 z" fill="rgb(44,50,50)" /></svg> 
*/

See the example in cmd/avatar-gen/main to save it as a .svg file.

If you just want to generate your avatar, without using the package, you can download the source code and run main with a string argument:

go run cmd/avatar/main.go mystring

it will create a file mystring.svg

Avatars

The SVGs avatars are created based on a MD5 hash from the input string, so it should aways be unique.

There's no randomness, so each input produce aways the same output. This means you don't have to store it and can run everytime you need.

The avatars have currently a fixed size of 300x300.

FAQs

Package last updated on 15 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc