+my @later;
+
+my $cols = { # foreground background
+ txt => [ '#000000', '#ffffff' ],
+ pins => [ '#ffffff', '#ff00ff' ],
+ vcc => [ '#ff0000', '#ffff00' ],
+ gnd => [ '#000000', '#00ffff' ],
+ i2c => [ '#008800', '#ffcccc' ],
+ serial=>[ '#000088', '#ccffcc' ],
+ spi => [ '#880000', '#ccccff' ],
+};
+
+sub swap_cols {
+ my $swap = shift;
+ die "$swap not found in ",dump($cols) unless $cols->{$swap};
+ my ( $c1, $c2 ) = @{ $cols->{$swap} };
+ $cols->{$swap} = [ $c2, $c1 ];
+}
+
+swap_cols 'txt' if $opt_invert;
+
+
+sub svg_style {
+ my ($name,$x,$y,$col) = @_;
+
+ return '' unless $opt_color;
+
+ $y -= $font_b; # shift box overlay to right vertical position based on font baseline
+
+ sub rect {
+ my ($x,$y,$col,$fill) = @_;
+ print qq{<rect x="$x" y="$y" height="2.54" width="}, $max_len[$col] * $font_w, qq{" style="fill:$fill;stroke:#ffffff;stroke-width:0.10" />\n};
+
+ }
+
+ if ( $name =~ m/^(\d+)$/ ) { # pins
+ my $pin = $1;
+ my ( $fg, $bg ) = @{ $cols->{pins} };
+ if ( $pin == 1 ) {
+ my $w = $max_len[$col]*$font_w - 0.1;
+ my $cx = $x + $w;
+ my $cy = $y + 2.54;
+ #print qq{<polygon points="$x,$y $cx,$y $x,$cy $x,$y" stroke="$fg" stroke-width="0.25" fill="$bg" />};
+ #print qq{<polygon points="$x,$cy $cx,$cy $cx,$y $x,$cy" stroke="$bg" stroke-width="0.25" fill="$fg" />};
+ print qq{<rect x="$x" y="$y" width="$w" height="2.54" stroke="$fg" stroke-width="0.3" fill="$bg" />};
+ my ( $fg, $bg ) = @{ $cols->{txt} };
+ print qq{<rect x="$x" y="$y" width="$w" height="2.54" rx="1" ry="1" stroke="$fg" stroke-width="0.3" fill="$bg" />};
+ } else {
+ rect $x,$y,$col,$fg;
+ }
+ return qq{ style="fill:$bg"};
+ }
+
+ if ( $name =~ m/(VCC|3V3|3.3V|5v)/i ) {
+ my ($fg,$bg) = @{ $cols->{vcc} };
+ rect $x,$y,$col,$bg;
+ return qq{ style="fill:$fg"};
+ } elsif ( $name =~ m/(G(ND|Round)|VSS|0v)/i ) {
+ my ($fg,$bg) = @{ $cols->{gnd} };
+ rect $x,$y,$col,$bg;
+ return qq{ style="fill:$fg"};
+ } elsif ( $name =~ m/\[(\w+)/ ) { # kernel
+ my $dev = $1;
+ my ($fg,$bg) = @{ $cols->{txt} };
+ $dev = 'serial' if $dev =~ m/^tty/;
+ ($fg,$bg) = @{ $cols->{$dev} } if exists $cols->{$dev};
+ rect $x,$y,$col,$bg;
+ return qq{ style="fill:$fg"};