identicon

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: MIT Imports: 5 Imported by: 0

README

Identicon

A Go library for Identicon generation

Latest Release Version Godoc Go Report Card codecov

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MD5

func MD5(text string) []byte

Helpers

func RGB

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

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
}

func New

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

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

Image interface ColorModel returns the Image's color model.

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
	Margin          int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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