Coder Social home page Coder Social logo

go-adorable's Introduction

go-adorable - Adorable Avatars from Go

The go-adorable project is a Go clone of Adorable Avatars, an image generator for user friendly placeholder avatars. This project's goal is to enable quickly onboarding users into social networks and providing a human centric starting experience.

random

Usage

The library's Go API is extremely simplistic, consisting of a handful of methods that can generate png images according to a few rules. The simplest is to just request a fully random image, which can generate 576 unique faces on a "limitless" background color palette.

avatar := adorable.Random()

if err := ioutil.WriteFile("avatar.png", avatar, 0600); err != nil {
  panic(err)
}

Determinism

Fully random images are useful for most purposes, but sometimes it may be desirable to assign a deterministic image to a specific user. This can be particularly handy for insta-onboarding or as a placeholder if no avatar is set.

avatar := adorable.PseudoRandom([]byte("unique-user-id"))

if err := ioutil.WriteFile("avatar.png", avatar, 0600); err != nil {
  panic(err)
}

pseudorandom

The deterministic avatars may be further restricted to a specific background palette, enabling finer tuned placeholders for default images (e.g. grayscale or other neutral colors). Note, that the images below are the same deterministic ones as above, just with fixed colors.

scheme := color.RGBA{R: 96, G: 128, B: 192, A: 255}
avatar := adorable.PseudoRandomWithColor([]byte("unique-user-id"), scheme)

if err := ioutil.WriteFile("avatar.png", avatar, 0600); err != nil {
  panic(err)
}

colored

Demo

The repository also contains a small demo which lists a few hundred avatars created with different invocation rules. It should be a good staring point if you get stuck or want to play around with the generator and quickly see a summary of the results. You can run it via:

$ go run ./samples.go

Credits

This repository is maintained by Péter Szilágyi (@karalabe), but authorship of the images belongs to the original avatars-api-middleware project and its artists, Kelly Rauwerdink (@missingdink) and Kevin Altman (@itsthatguy).

License

Same as original, MIT.

go-adorable's People

Contributors

karalabe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.