Initial page based on Agency by http://startbootstrap.com
This commit is contained in:
commit
838774e06d
84 changed files with 8146 additions and 0 deletions
32
_plugins/hex_to_rgb.rb
Normal file
32
_plugins/hex_to_rgb.rb
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# Simple hex conversion Liquid filter plugin
|
||||
#
|
||||
# Convert a string of hex values into an array of decimal values.
|
||||
#
|
||||
# Examples:
|
||||
# {{ "aabbcc" | hex_to_rgb }}
|
||||
# # => [170, 187, 204]
|
||||
#
|
||||
# {{ "abc" | hex_to_rgb }}
|
||||
# # => [170, 187, 204]
|
||||
#
|
||||
# {{ "0a0b0c" | hex_to_rgb }}
|
||||
# # => [10, 11, 12]
|
||||
#
|
||||
# hexval - string of valid hexidecimal characters
|
||||
#
|
||||
# Returns an array of decimal values for the parse hex characters
|
||||
#
|
||||
|
||||
module Jekyll
|
||||
module HexToRGB
|
||||
def hex_to_rgb(hexval)
|
||||
if hexval.length.even?
|
||||
hexval.scan(/../).map {|color| color.to_i(16)}
|
||||
else
|
||||
hexval.scan(/./).map {|color| (color+color).to_i(16)}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_filter(Jekyll::HexToRGB)
|
||||
Loading…
Add table
Add a link
Reference in a new issue