Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Identicon ¶
type Identicon struct { Identifier string // contains filtered or unexported fields }
Identicon defines an identicon.
func New ¶
New returns the identicon for given identifier. Additional options can specify the identicon. DefaultOptions() will be used as a baseline.
Example ¶
package main import ( "image/color" "image/png" "log" "os" "github.com/tsdtsdtsd/identicon" ) func main() { icon, err := identicon.New("michael@example.com", identicon.WithBGColor(color.RGBA{220, 220, 220, 255})) if err != nil { log.Fatal(err) } file, err := os.Create("identicon.png") if err != nil { log.Fatal(err) } err = png.Encode(file, icon.Image()) if err != nil { log.Fatal(err) } file.Close() }
Output:
func (*Identicon) HashString ¶
HashString returns the hexadacimal representation of the hash as string.
type Image ¶ added in v1.1.0
type Image struct {
// contains filtered or unexported fields
}
func (*Image) At ¶ added in v1.1.0
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 (*Image) Bounds ¶ added in v1.1.0
Bounds returns the domain for which At can return non-zero color.
func (*Image) ColorModel ¶ added in v1.1.0
ColorModel returns the Image's color model.
type Option ¶
type Option func(*Identicon)
Option changes a single option
func WithBGColor ¶
WithBGColor returns an option that sets the identicon's background color to given color.
func WithFGColor ¶
WithFGColor returns an option that sets the identicon's background color to given color.
func WithHasher ¶
WithHasher returns an option that sets the identicon's hash generator. The option will be discarded silently if nil given.
func WithImageSize ¶
WithImageSize returns an option that sets the identicon's image size to given amount. The option will be discarded silently if given value is non-positive.
func WithResolution ¶
WithResolution returns an option that sets the identicon's grid resolution to given amount. The option will be discarded silently if given value is non-positive.