about summary refs log tree commit diff stats
path: root/lib/Fornax/Hex2RGB.rakumod
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-11-03 20:20:07 +0530
committerAndinus <andinus@nand.sh>2021-11-03 20:20:07 +0530
commit4e8a59668535badfe7e1975f52fb04489e467585 (patch)
treeafd544bae4cc02d98272a311e6c7eeba986818cf /lib/Fornax/Hex2RGB.rakumod
parentef6d6b1048fcbab12016b46ea6177a41078e7759 (diff)
downloadfornax-4e8a59668535badfe7e1975f52fb04489e467585.tar.gz
Parse fornax format to generate the images
Switched to PNG because SVGs were larger in this case. Also, video
will be created with `ffmpeg` so it's just easier to use PNGs.
Diffstat (limited to 'lib/Fornax/Hex2RGB.rakumod')
-rw-r--r--lib/Fornax/Hex2RGB.rakumod8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Fornax/Hex2RGB.rakumod b/lib/Fornax/Hex2RGB.rakumod
new file mode 100644
index 0000000..aa77739
--- /dev/null
+++ b/lib/Fornax/Hex2RGB.rakumod
@@ -0,0 +1,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
+}