9.0
top
← prev up next →

IdentikonπŸ”— i

Darren Newton <info@v25media.com>

A small framework for generating identicons.

1Installation & updatesπŸ”— i

At the command line:

raco pkg install identikon

After that, you can update the package from the command line:

raco pkg update identikon

Identikon has a full command line interface which you can view with

raco identikon --help

2Generating identiconsπŸ”— i

procedure

( identikon width
height
input
[ rules
#:filenameboolean?])image?
input:(or/c symbol? string? )
rules:(or/c symbol? string? )="default"
boolean?:#t=#f
Identikon provides a single function, identikon , which produces images based on input. If input is a string or symbole, a SHA1 hash will be produced and used to geneate an image. If a filename is provided a SHA1 of the file will be produced and used as input for generating images.

Produces an identikon with dimensions specified by width and height.

input is converted into a list of numbers based on a SHA1 hash and passed to a rules module for processing into an image?.

rules is the name of the rules module to use in generating the identicon. This defaults to "default".

If #:filename is #t then identikon will treat the value of input as a filename and attempt fo open it for processing.

Examples:

Create a 300x300px identicon for "racket" using the "default.rkt" rule module.

Example:
> (identikon 300300"racket")

Create a 300x300 identicon for "racket" using the "squares.rkt" rule module.

Example:
> (identikon 300300"racket"'squares)

procedure

( save-identikon filename
type
image
[ #:qualitynumber?])(or/c void? exn:fail? )
filename:string?
image:image?
number?:natural-number/c =75
Save an identikon image to disk. Available types are svg, png and jpeg. If the file already exists, a new version of the file will be saved with a timestamp (seconds) appended.

#:quality only affects jpeg images.

(save-identikon "foo"'png
(identikon 300300'racket'qbert))

procedure

image
[ #:qualitynumber?])string?
image:image?
number?:natural-number/c =75
Return an identikon in a string format. This is useful if you want to inject the image directly into an HTML page as an <svg/> element or as a data-uri.

Available types are svg, png and jpeg.

svg will emit a well formed SVG element.

png and jpeg types will emit a string of base-64 encoded bytes suitable for use in an HTML data-uri.

#:quality only affects jpeg images.

(identikon->string (identikon 300300'racket'qbert)'svg)

3Rules modulesπŸ”— i

All rules modules must provide a single draw-rules function and live in the rules folder.

procedure

( draw-ruleswidthheightuser)image?

Example:
> (draw-rules
200
200
'(2718020017618977681561211209117218721463814418424176))

4License & source codeπŸ”— i

This module is under the MIT license.

Source repository at https://github.com/DarrenN/identikon. Suggestions, corrections and pull-requests welcome.

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /