5 # Converter for POV-Ray gradient files produced by The Gimp
7 # Copyright (C) 2002 Mark R. Shinwell
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 my $interval = 1.0 / ($points-1);
37 if ($l =~ /.*\[(\d\.\d+) color rgbt <(\d\.\d+), (\d\.\d+), (\d\.\d+).*/) {
39 my $r = int($2 * 255);
40 my $g = int($3 * 255);
41 my $b = int($4 * 255);
43 while ($pos >= $next) {
50 my $faralong = $next - $prevpos;
51 my $total = $pos - $prevpos;
52 my $frac = $faralong / $total;
54 my $newr = $pr + int(($r - $pr) * $frac);
55 my $newg = $pg + int(($g - $pg) * $frac);
56 my $newb = $pb + int(($b - $pb) * $frac);
58 $outputr = "$outputr, $newr";
59 $outputg = "$outputg, $newg";
60 $outputb = "$outputb, $newb";
73 print "/* Generated by $0 */\n";
74 print "static const unsigned char REDS[] = {$outputr, 230};\n";
75 print "static const unsigned char GREENS[] = {$outputg, 230};\n";
76 print "static const unsigned char BLUES[] = {$outputb, 230};\n";