6 my @defaultkeys = qw/_color _floodlight/;
11 @colorkeys = map { $_ eq '-' ? map { "-$_" } @defaultkeys : $_ eq '+' ? @defaultkeys : $_ } @colorkeys;
12 print STDERR "Remapping keys: @colorkeys\n";
14 sub Image_LinearFloatFromsRGBFloat($) {($_[0] <= 0.04045) ? $_[0] * (1.0 / 12.92) : (($_[0] + 0.055)*(1.0/1.055)) ** 2.4}
15 sub Image_sRGBFloatFromLinearFloat($) {($_[0] < 0.0031308) ? $_[0] * 12.92 : 1.055 * ($_[0] ** (1.0/2.4)) - 0.055}
21 if(/^\s*"([^"]*)"\s+"\s*([-+0-9.]+)\s*([-+0-9.]+)\s*([-+0-9.]+)\s*"\s*$/i)
27 if(grep { /^\+?\Q$key\E$/i } @colorkeys)
29 $r = Image_LinearFloatFromsRGBFloat $r;
30 $g = Image_LinearFloatFromsRGBFloat $g;
31 $b = Image_LinearFloatFromsRGBFloat $b;
32 $line = "\"$key\" \"$r $g $b\"";
34 elsif(grep { /^-\Q$key\E$/i } @colorkeys)
36 $r = Image_sRGBFloatFromLinearFloat $r;
37 $g = Image_sRGBFloatFromLinearFloat $g;
38 $b = Image_sRGBFloatFromLinearFloat $b;
39 $line = "\"$key\" \"$r $g $b\"";
42 elsif(/^\s*"_floodlight"\s+"\s*([-+0-9.]+)\s*([-+0-9.]+)\s*([-+0-9.]+)(\s*.*)"\s*$/i)
48 if(grep { /^\+?_floodlight$/i } @colorkeys)
50 $r = 255.0*Image_LinearFloatFromsRGBFloat($r/255.0);
51 $g = 255.0*Image_LinearFloatFromsRGBFloat($g/255.0);
52 $b = 255.0*Image_LinearFloatFromsRGBFloat($b/255.0);
53 $line = "\"_floodlight\" \"$r $g $b$rest\"";
55 elsif(grep { /^-_floodlight$/i } @colorkeys)
57 $r = 255.0*Image_sRGBFloatFromLinearFloat($r/255.0);
58 $g = 255.0*Image_sRGBFloatFromLinearFloat($g/255.0);
59 $b = 255.0*Image_sRGBFloatFromLinearFloat($b/255.0);
60 $line = "\"_floodlight\" \"$r $g $b$rest\"";
65 print STDERR "Converting: $_ -> $line\n";