xidenticon

package
v0.0.0-...-89edfd8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package identicon helps generating deterministic user identicons

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MD5

func MD5(text string) []byte

MD5 returns MD5 hash of given input string as byte slice

func RGB

func RGB(r, g, b uint8) color.NRGBA

RGB returns color.NRGBA struct for given red, green and blue values

Types

type Identicon

type Identicon struct {
	Color   color.Color
	Hash    []byte
	ID      string
	Options *Options
	Tiles   [][]bool
	// Pix holds the image's pixels, in R, G, B, A order. The pixel at
	// (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4].
	Pix []uint8
	// Stride is the Pix stride (in bytes) between vertically adjacent pixels.
	Stride int
	// Rect is the image's bounds.
	Rect image.Rectangle
}

Identicon defines an identicon

func New

func New(ID string, opts *Options) (*Identicon, error)

New returns a new identicon based on given ID string

func (*Identicon) At

func (ic *Identicon) At(x, y int) color.Color

At returns the color of the pixel at (x, y). At(Bounds().Min.X, Bounds().Min.Y) returns the upper-left pixel of the grid. At(Bounds().Max.X-1, Bounds().Max.Y-1) returns the lower-right one.

func (*Identicon) Bounds

func (ic *Identicon) Bounds() image.Rectangle

Bounds returns the domain for which At can return non-zero color.

func (*Identicon) ColorModel

func (ic *Identicon) ColorModel() color.Model

ColorModel returns the Image's color model.

func (*Identicon) HashString

func (ic *Identicon) HashString() string

HashString returns hash value as string

func (*Identicon) NRGBAAt

func (ic *Identicon) NRGBAAt(x, y int) color.NRGBA

NRGBAAt returns the color of the pixel at (x, y) as color.NRGBA.

func (*Identicon) PixOffset

func (ic *Identicon) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*Identicon) Set

func (ic *Identicon) Set(x, y int, c color.Color)

Set stores given color at position (x, y).

type Options

type Options struct {
	BackgroundColor color.NRGBA
	Debug           bool
	ImageSize       int
}

Options control some inner mechanics

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL