]> de.git.xonotic.org Git - xonotic/mediasource.git/blobdiff - gfx/luma/tools/color-convert.pl
First batch of Luma theme sourcefiles
[xonotic/mediasource.git] / gfx / luma / tools / color-convert.pl
diff --git a/gfx/luma/tools/color-convert.pl b/gfx/luma/tools/color-convert.pl
new file mode 100755 (executable)
index 0000000..35354d5
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+# TASK
+#   Convert color values from hexadecial to floating point and vice versa.
+#
+# USAGE
+#   $0 [RRGGBB | R.R G.G B.B]
+
+
+use strict;
+use warnings;
+
+
+if (@ARGV == 1)
+{
+       printf("%.2g %.2g %.2g\n",
+               hex(substr($ARGV[0], 0, 2)) / 255,
+               hex(substr($ARGV[0], 2, 2)) / 255,
+               hex(substr($ARGV[0], 4, 2)) / 255);
+
+}
+elsif (@ARGV == 3)
+{
+       printf("%02x%02x%02x\n",
+               int($ARGV[0]*255 + 0.5),
+               int($ARGV[1]*255 + 0.5),
+               int($ARGV[2]*255 + 0.5));
+}