qidenticon

package module
v0.0.0-...-5c327fb Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2017 License: BSD-2-Clause Imports: 6 Imported by: 5

README

qidenticon (from Bitmessage) ported to Go

Sample icons

Sample icons

Example

package main

import (
	"image/png"
	"os"

	"github.com/jakobvarmose/go-qidenticon"
)

func main() {
	code := qidenticon.Code("test")
	size := 30
	settings := qidenticon.DefaultSettings()
	img := qidenticon.Render(code, size, settings)
	w, err := os.Create("test.png")
	if err != nil {
		panic(err)
	}
	defer w.Close()
	err = png.Encode(w, img)
	if err != nil {
		panic(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Code

func Code(str string) uint64

Code derives a code for use with Render.

func Render

func Render(code uint64, totalSize int, settings *Settings) image.Image

Render generates an identicon. code is a code derived by the Code function. totalSize specifies the total size in pixels. It is recommended that this is divisible by 3.

Types

type Settings

type Settings struct {
	// TwoColor specifies if the identicon should be
	// generated using one or two colors.
	TwoColor bool

	// Alpha specifies the transparency of the generated identicon.
	Alpha uint8
}

func DefaultSettings

func DefaultSettings() *Settings

DefaultSettings returns a Settings object with the recommended settings.

Jump to

Keyboard shortcuts

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