From: Dobrica Pavlinusic Date: Wed, 8 Nov 2017 23:41:09 +0000 (+0100) Subject: optimize for inkjet colors (to create something readable) X-Git-Url: http://git.rot13.org/?p=linux-gpio-pinout;a=commitdiff_plain;h=7dc83b14794e9ea3e2d717504d1377d4b773b5ba optimize for inkjet colors (to create something readable) --- diff --git a/gpio.pl b/gpio.pl index f9ddfb4..a8aae15 100755 --- a/gpio.pl +++ b/gpio.pl @@ -7,14 +7,19 @@ use Getopt::Long; my $opt_svg = $ENV{SVG} || 0; my $opt_alt = $ENV{ALT} || 1; +my $opt_invert = $ENV{INVERT} = 1; GetOptions( 'svg!' => \$opt_svg, 'alt!' => \$opt_alt, + 'invert!' => \$opt_invert, ); # svg font hints my $font_w = 1.67; # < 2.54, font is not perfect square +my $txt_color = '#000000'; + $txt_color = '#ffffff' if $opt_invert; + sub slurp { open(my $fh, '<', shift); local $/ = undef; @@ -115,27 +120,20 @@ if ( $opt_svg ) { width="210mm"> - - - - - - - + }; # svg, insert rest of rect + print qq{} if $opt_invert; } my @later; -my @pin_cols = ( '#ffffff', '#000000' ); +my $cols = { # foreground background + pins => [ '#ffffff', '#ff00ff' ], + vcc => [ '#ff0000', '#ffff00' ], + gnd => [ '#000000', '#00ffff' ], +}; sub svg_style { my ($name,$x,$y,$col) = @_; @@ -148,17 +146,19 @@ sub svg_style { } if ( $name =~ m/^\d+$/ ) { # pins - my ( $c1, $c2 ) = @pin_cols; + my ( $c1, $c2 ) = @{ $cols->{pins} }; rect $x,$y,$col,$c1; return qq{ style="fill:$c2"}; } if ( $name =~ m/(VCC|3V3)/i ) { - rect $x,$y,$col,'#000000'; - return qq{ style="fill:#ffcc88"}; + my ($fg,$bg) = @{ $cols->{vcc} }; + rect $x,$y,$col,$bg; + return qq{ style="fill:$fg"}; } elsif ( $name =~ m/(G(ND|Round)|VSS)/i ) { - rect $x,$y,$col,'#000000'; - return qq{ style="fill:#ff8800"}; + my ($fg,$bg) = @{ $cols->{gnd} }; + rect $x,$y,$col,$bg; + return qq{ style="fill:$fg"}; } else { return ''; } @@ -179,7 +179,7 @@ foreach my $line ( @line_parts ) { if ( $opt_svg ) { - my $tspan = qq{}; + my $tspan = qq{}; my $x_pos = $x; foreach my $i ( @cols_order ) { @@ -193,8 +193,8 @@ foreach my $line ( @line_parts ) { $y += 2.54; # swap pin colors - my ( $c1, $c2 ) = @pin_cols; - @pin_cols = ( $c2, $c1 ); + my ( $c1, $c2 ) = @{ $cols->{pins} }; + $cols->{pins} = [ $c2, $c1 ]; } else {