diff options
Diffstat (limited to 'lib/Octans/Hex2RGB.rakumod')
-rw-r--r-- | lib/Octans/Hex2RGB.rakumod | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Octans/Hex2RGB.rakumod b/lib/Octans/Hex2RGB.rakumod new file mode 100644 index 0000000..72cb848 --- /dev/null +++ b/lib/Octans/Hex2RGB.rakumod @@ -0,0 +1,10 @@ +# This module has been adapted from Fornax::Hex2RGB. + +#| Takes hex value and returns RGB equivalent. +sub hex2rgb(Str $hex --> List) is export { + # Skip the first character, group each by 2 and parse as base 16. + # Divide by 255 to return value between 0, 1. + $hex.comb.skip.rotor(2).map( + *.join.parse-base(16) / 255 + )>>.Rat +} |