Skip to content
Branch: master
Go to file
Code

Latest commit

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

a b c

identikon

A small collection of Racket scripts for generating identicons. This is very much alpha and will be changing a lot as I learn more about Racket. Identicons can be saved as PNG or SVG. Obligatory blog post.

Install

$ raco pkg install identikon

Dependencies

You will need to install sugar, quickcheck and css-tools.

Usage

Requiring identikon in Dr. Racket or Emacs with racket-mode or Geiser will give you access to the identikon function in the REPL:

(require identikon)

; Generate a default 300px identicon for "racket"
(identikon 300 300 "racket")

; Generate a q*bert style 300px identicon for "racket"
(identikon 300 300 "racket" "qbert")

; Generate a q*bert style 300px identicon for "racket" and save as an svg
(identikon 300 300 "racket" "qbert" "svg")

; start having real fun with identicons
(require identikon
         2htdp/image)

(define foo (identikon 200 200 "foo"))
(define bar (identikon 200 200 "bar"))
(beside
 (above foo bar)
 (above bar foo))

Note: Trying to use identikon in a standard CLI racket REPL will just return an (object:image% ...) instead of rendering the image. You could save an image to the filesystem this way: (identikon 300 300 "racket" "default" "svg"). If you're accessing the CLI REPL via either racket-mode or Geiser in Emacs then the images will render just fine like so:

geiser

CLI interface (via Raco)

-h  Help
-s  (multi) Size (all identikons are currently squares)
-i  String to convert to identicon
-f  File or input stream used to generate identikon
-r  (optional) Ruleset to use
-t  (optional) Filetype to save as: "png" or "svg"; defaults to png

$ raco identikon -s 300 -i "FooBarBaz"

$ raco identikon -s 300 -i "FooBarBaz" -r "squares"

$ raco identikon -s 300 -i "FooBarBaz" -r "squares" -t "svg"

$ raco identikon -s 300 -s 200 -s 100 -i "FooBarBaz" -r "stars" -t "svg"

Built-in rule sets

Each identicon has a rules file (ex: default.rkt) which is responsible for taking the input data and generating an image as it sees fit. There are a few existing rule sets to play with.

default.rkt

d

qbert.rkt

s

squares.rkt

s

circles.rkt

c

angles.rkt

a

angles2.rkt

a

nineblock.rkt

n

stars.rkt

s

rings.rkt

r

You can’t perform that action at this time.