icon

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const ContentType = "image/svg+xml"

ContentType describes the content type which should be echoed back to clients when writing generated icons to http responses.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator interface {

	// Id provides a simple url friendly identifier via which this generator may be referenced when
	// multiple are exposed.
	Id() string

	// Size identifies the width and height of this particular icon as defined within the generated
	// vector file.
	Size() uint

	// Write produces a new image for the given payload and writes its contents to the given writer.
	Write(input []byte, writer io.Writer)

	// Draw generates an icon for the given payload and writes its contents to the SVG at the current
	// location.
	Draw(input []byte, canvas *svg.SVG)
}

Generator provides a generation function for a given style of identicon.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry encapsulates a set of known generators.

func EmptyRegistry

func EmptyRegistry() *Registry

EmptyRegistry creates a new registry devoid of any known generators.

func NewRegistry

func NewRegistry(generators ...Generator) *Registry

NewRegistry creates a registry with the given generator implementations.

func (*Registry) Get

func (r *Registry) Get(id string) Generator

Get retrieves a given generator from this registry.

func (*Registry) Ids

func (r *Registry) Ids() []string

Ids returns a list of known generator identifiers within this registry.

func (*Registry) Register

func (r *Registry) Register(generator Generator)

Register introduces a new generator to this registry.

If a generator with the given identifier is already present within the registry, it will be replaced with the passed value.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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