Debian Codegraph @

texmf-dist/doc/latex/ifmslide/genbutton

raw
1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
2 if 0;
3 use strict;
4
5 #
6 # That was one of my first perl-scripts, so excuse the style...
7 # Thomas Emmel <[email protected]> 7/2000
8 #
9 #
10
11 my $usage = <<"EOFUSE";
12 Syntax: genbutton [options] <eps file>
13 Options:
14 --proto=<file>: prototype for the output file
15 --output=<file>: output file
16 --scolor=xxx,xxx,xxx: Start with Color RGB 0-255
17 --ecolor=xxx,xxx,xxx: End with Color RGB 0-255
18 EOFUSE
19
20 # options
21 $::opt_proto="";
22
23 use Getopt::Long;
24 GetOptions (
25 "proto=s",
26 "output=s",
27 "scolor=s",
28 "ecolor=s",
29 ) or die $usage;
30
31 my $proto = $::opt_proto;
32 my $output = $::opt_output;
33 my $scolor = $::opt_scolor;
34 my $ecolor = $::opt_ecolor;
35
36 my @srgblist = split(/,/,$scolor);
37 my @ergblist = split(/,/,$ecolor);
38
39 # count lines with field number 4 is "rg" in proto
40
41 print STDOUT "p=$proto, o=$output, s=@srgblist, e=@ergblist \n";
42
43 open(PROTO,$proto) || die "Cannot open $proto for reading!";
44 open(OUT,">$output") || die "Cannot open $output for writing!";
45
46 my $numoflevels = 0;
47
48 while (<PROTO>) {
49 chomp; # strip record separator
50 my @Fld = split(' ', $_, 5);
51 my $fldlength = @Fld;
52 if ($Fld[3] eq 'rg' ){ # && $fldlength == 4) {
53 $numoflevels++;
54 # print $Fld[1] . ' ' . $Fld[1] . ' ' . $Fld[1] . ' rg';
55 # print " $fldlength \n";
56 }
57 }
58
59 print "$numoflevels\n" ;
60
61 my @diffcolors = (0,0,0);
62 my $i;
63
64 for ($i=0;$i<=2;$i++)
65 { $diffcolors[$i]= ($ergblist[$i]-$srgblist[$i])/($numoflevels-1)/255;
66 $srgblist[$i]*=1/255; }
67
68 # and again...
69 open(PROTO,$proto);
70
71 while (<PROTO>) {
72 chomp; # strip record separator
73 my @Fld = split(' ', $_, 5);
74 my $fldlength = @Fld;
75 if ($Fld[3] eq 'rg' ){ # && $fldlength == 4) {
76 print OUT $srgblist[0] . ' ' . $srgblist[1] . ' ' . $srgblist[2] . ' rg';
77 print OUT " \n";
78 $srgblist[0]+=$diffcolors[0];
79 $srgblist[1]+=$diffcolors[1];
80 $srgblist[2]+=$diffcolors[2];
81 } else
82 { print OUT "$_\n"; }
83 }
84
85
86 print "@diffcolors \n";
87
88
89 #input=$1
90 #cat $input | awk '{if ($4 == "rg") print $1" "$1" "$1" rg"; else print $0 }'