]> de.git.xonotic.org Git - xonotic/mediasource.git/blob - gfx/luma/tools/color-convert.pl
Update the luma sourcefiles
[xonotic/mediasource.git] / gfx / luma / tools / color-convert.pl
1 #!/usr/bin/perl
2 # TASK
3 #   Convert color value from hexadecial to floating point and vice versa.
4 #
5 # USAGE
6 #   ./color-convert.pl [RRGGBB | R.R G.G B.B]
7
8
9 use strict;
10 use warnings;
11
12
13 if (@ARGV == 1)
14 {
15         printf("%.2g %.2g %.2g\n",
16                 hex(substr($ARGV[0], 0, 2)) / 255,
17                 hex(substr($ARGV[0], 2, 2)) / 255,
18                 hex(substr($ARGV[0], 4, 2)) / 255);
19
20 }
21 elsif (@ARGV == 3)
22 {
23         printf("%02x%02x%02x\n",
24                 int($ARGV[0]*255 + 0.5),
25                 int($ARGV[1]*255 + 0.5),
26                 int($ARGV[2]*255 + 0.5));
27 }