Identicon
Who Am I?
Jonathan Clarkin
What is It?
I bet you've seen these avatars in forums before...
StackOverflow | GitHub | Wordpress | etc
What is it?
A generated user icon pattern
that is unique to each user
What Is It?
Demo!
Embedded Demo
(if iframe is allowed..?)
Pattern
Show me the pattern!
pattern
3x3
PATTERN
Corners + Edges + Center
+
Colour
pattern
16 tiles
A set of potential patterns to use to create the icon
Pattern
16 Tiles in JavaScript
Uniqueness
What choices are available for making this icon?
Uniqueness
Corners (same for Edges)
- 24 - Pattern choices (16 defined)
- 21 - Invert Colour Scheme choices (Yes or No)
- 22 - Pattern rotation choices (although some may be identical)
Middle
- 22 - Pattern choices (only 4 symmetric patterns in the set)
- 21 - Invert Colour Scheme choices (Yes or No)
Colour
- 25 - Red Pallet choices (limited to 32)
- 25 - Blue Pallet choices (limited to 32)
- 25 - Green Pallet choices (limited to 32)
Uniqueness
Lets store this as bits!
Total of 22 bits... 4 Million Unique Options !
Generated
What info can we use
to generate the unique 22 bits?
generated
The username!
generated
Convert the username to a bit hash
using Javascript
Generated
Examples:
'Ottawa JS'
1000000110000111010001101010011
'Hackers United'
110000001010000110100111001111110
'Benjamin Sisko'
101101001111010110011010101110001
generated
Use the hash to pick characteristics
generated
Use the characteristics to create the icon
& Render them to the HTML 5 Canvas
Draw to the Canvas
var node = document.querySelector('canvas'); var ctx = node.getContext("2d"); // Setup the default paintbrush and save ctx.fillStyle = "white"; ctx.save(); // Restore Point // paint background white ctx.fillRect(x, y, size, size); // Setup the coloured paintbrush ctx.fillStyle = "fuchsia"; // Draw Patch ctx.beginPath(); ctx.moveTo(x,y); ctx.lineTo(x,y); ... for all coordinates of the shape ... ctx.closePath(); ctx.fill(); //draw to screen ctx.restore(); // Restore back to white
Demo - Drawing on Canvas
Final Product
Your identicon!
A generated user icon pattern
Go Forth
and build a custom one!
Different Patch Patterns
Sizes: 4x4, 8x8, ...
Different Symmetries
Identicon
By Jonathan Clarkin
Identicon
- 1,038