cameron

package module
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 5 Imported by: 9

README

Cameron

Test codecov Go Report Card Go Reference

An avatar generator for Go.

Fun fact, Cameron is named after James Cameron, the director of Avatar.

Features

Installation

To use this project programmatically, go get it:

go get github.com/aofei/cameron

Quickstart

Create a file named cameron.go:

package main

import (
	"image/png"
	"net/http"

	"github.com/aofei/cameron"
)

func main() {
	http.ListenAndServe("localhost:8080", http.HandlerFunc(identicon))
}

func identicon(rw http.ResponseWriter, req *http.Request) {
	img := cameron.Identicon([]byte(req.RequestURI), 70)
	rw.Header().Set("Content-Type", "image/png")
	png.Encode(rw, img)
}

Then run it:

go run cameron.go

Finally, visit http://localhost:8080 with different paths.

Community

If you have any questions or ideas about this project, feel free to discuss them here.

Contributing

If you would like to contribute to this project, please submit issues here or pull requests here.

When submitting a pull request, please make sure its commit messages adhere to Conventional Commits 1.0.0.

License

This project is licensed under the MIT License.

Documentation

Overview

Package cameron implements an avatar generator for Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Identicon

func Identicon(data []byte, cell int) image.Image

Identicon returns an identicon avatar as an image.Image that is visually identical to https://github.com/identicons/{login}.png. All geometric rules, color calculations, and pixel layouts match the implementation GitHub uses in production.

Note that the final image is a square of 6*cell pixels from a 5x5 grid plus a half-cell margin on every side.

Types

This section is empty.

Jump to

Keyboard shortcuts

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