Created
February 6, 2014 22:28
-
-
Save richardmcmillen-examtime/8853812 to your computer and use it in GitHub Desktop.
RubyIdenticon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ruby_identicon' | |
# background_color: (Integer, default 0) the background color of the identicon in rgba notation (e.g. xffffffff for white) | |
# border_size: (Integer, default 35) the size in pixels to leave as an empty border around the identicon image | |
# grid_size: (Integer, default 7) the number of rows and columns in the identicon, minimum 4, maximum 9 | |
# square_size: (Integer, default 50) the size in pixels of each square that makes up the identicon | |
# key: (String) a 16 byte key used by siphash when calculating the hash value (see note below) | |
# | |
# Varying the key ensures uniqueness of an identicon for a given title, it is assumed desirable for different applications | |
# to use a different key. | |
Dir.mkdir("tmp") unless File.directory?("tmp") | |
options = { | |
grid_size: 7, | |
square_size: 50, | |
background_color: 0, | |
border_size: 35 | |
} | |
time = Time.now.strftime('%H_%M_%S') | |
filename = "identicon_#{options[:grid_size]}_#{options[:square_size]}_#{time}" | |
RubyIdenticon.create_and_save('examtime', "tmp/#{filename}.png", options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment