about summary refs log tree commit diff stats
path: root/lib/Fornax/Hex2RGB.rakumod
blob: aa7773981e528d8b8d4fa4632a4f1459b9c7b208 (plain) (blame)
1
2
3
4
5
6
7
8
#| 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
}