identicon

package module
v0.0.0-...-ab19b58 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: MIT Imports: 11 Imported by: 3

README

identicon

identicon is a github's Identicons clone in Go

Simple example

Type: Horizontal, Theme: White (Default)

package main

import "github.com/1l0/identicon"

func main() {
	id := identicon.New()
	id.GeneratePNGToFile("identicons/default")

Type: Vertical, Theme: Black

	id.Type = identicon.Mirrorv
	id.Theme = identicon.Black
	id.GeneratePNGToFile("identicons/vertical_black")

Divisions: 7, Theme: Gray

	id.Type = identicon.Mirrorh
	id.Theme = identicon.Gray
	id.Q = 50
	id.Div = 7
	id.GeneratePNGToFile("identicons/div7_gray")

Margin: 140, Theme: Free

	id.Theme = identicon.Free
	id.Q = 70
	id.Div = 5
	id.Margin = 140
	id.GeneratePNGToFile("identicons/margin140_free")

Type: Normal, Theme: White

	id.Type = identicon.Normal
	id.Theme = identicon.White
	id.Margin = 35
	id.GeneratePNGToFile("identicons/normal_white")

Random batch

	id = identicon.New()
	id.GenerateRandomThemes("identicons/rand", 4)

Sequential batch

	id.GenerateSequentialThemes("identicons/seq", 1)
}

Documentation

Index

Constants

View Source
const (

	// Types
	Normal  int = iota
	Mirrorh     // Mirroring horizontal
	Mirrorv     // Mirroring vertical

	// Themes
	White
	Black
	Gray
	Free
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Identicon

type Identicon struct {
	Type   int
	Theme  int
	Q      int // Quantity px
	Div    int // Divisions
	Margin int // px
}

func New

func New() *Identicon

func (*Identicon) GeneratePNG

func (id *Identicon) GeneratePNG(w io.Writer) error

func (*Identicon) GeneratePNGToFile

func (id *Identicon) GeneratePNGToFile(p string) error

func (*Identicon) GenerateRandomThemes

func (id *Identicon) GenerateRandomThemes(p string, n int) error

func (*Identicon) GenerateSequentialThemes

func (id *Identicon) GenerateSequentialThemes(p string, n int) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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