Documentation

Overview

    Package avatar is reponsible for creating avatar images Thanks to https://github.com/taironas/tinygraphs

    Package avatar is reponsible for creating avatar images Thanks to https://github.com/taironas/tinygraphs

    Index

    Constants

    This section is empty.

    Variables

    View Source
    var (
    	// ErrNoSuchScheme gets returned when there is no such color scheme
    	ErrNoSuchScheme = errors.New("No such scheme")
    )
    View Source
    var Pallete = map[string][]color.RGBA{
    	"blue": {
    		{3, 63, 99, 255},
    		{40, 102, 110, 255},
    		{80, 197, 183, 255},
    		{255, 251, 255, 255},
    	},
    	"orange": {
    		{250, 121, 33, 255},
    		{254, 153, 32, 255},
    		{252, 252, 98, 255},
    		{255, 251, 255, 255},
    	},
    	"green": {
    		{0, 127, 95, 255},
    		{43, 147, 72, 255},
    		{85, 166, 48, 255},
    		{255, 251, 255, 255},
    	},
    }

    Functions

    func GetRandomPalette

    func GetRandomPalette() string

      GetRandomPalette returns a random palette

      func Palette

      func Palette(paletteName string) ([]color.RGBA, bool)

        Palette returns a color palette with the provided 'paletteName'

        func Palettes

        func Palettes() []string

          Palettes returns the names of available color palettes

          Types

          type Avatar

          type Avatar struct {
          	Width       int
          	Height      int
          	Size        string
          	Data        string
          	RawData     string
          	Image       *image.RGBA
          	ImageBuffer *bytes.Buffer
          }

            Avatar represents an avatar image

            func New

            func New(size int, data string) *Avatar

              New creates a new avatar struct and returns it

              func (*Avatar) Encode

              func (a *Avatar) Encode() error

                Encode encodes the generated image as a JPEG image and writes it to ImageBuffer

                func (*Avatar) Generate

                func (a *Avatar) Generate(basePath string) error

                  Generate will generate an avatar, encode and save it

                  func (*Avatar) GenerateImage

                  func (a *Avatar) GenerateImage(paletteName string) error

                    GenerateImage generates a new 6 x 6 quadrant avatar based on the data (hashed by MD5) and specified color palette

                    func (*Avatar) Save

                    func (a *Avatar) Save(base, size, name string) error

                      Save saves the encoded image in ImageBuffer to disk at path base + size + name.jpg