chiark / gitweb /
layout: support transparent colour setting, for loc label backgrounds
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 7 Nov 2010 17:16:40 +0000 (17:16 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 7 Nov 2010 17:20:05 +0000 (17:20 +0000)
layout/README.layout
layout/layout

index 1dcc45fa781f3c6453d0886beea6c371bc8fe0e5..32bbae7bf91da5d9c3fc3088a1d6cbbde2ca0558 100644 (file)
@@ -282,6 +282,7 @@ Command-line options
              <name>       name from rgb.txt
              #<R><G><B>   where R G B are each the same number of hex digits
               %<ps>       literal postscript <ps> eg  0.5 setgray
+             -            transparent (for element "l" only)
 
  -q       quiet: do not print info to stderr
           (default: prints bounding box, at the moment)
index df1712653fe9049ac026ea1db95d57483b64d759..d1ba71732618281b34855835e5a793e1866869c5 100755 (executable)
@@ -77,6 +77,8 @@ sub parse_colour ($) {
        $rgbmax= (1 << ($l1 * 4))-1;
     } elsif ($spec eq '') {
        return '';
+    } elsif ($spec eq '-') {
+       return $spec;
     } elsif ($spec =~ m/^\%/) {
        return $';
     } else {
@@ -131,6 +133,8 @@ while (@ARGV && $ARGV[0] =~ m/^\-/) {
            my @defs= split //, $1;
            my $nc= parse_colour($2);
            foreach my $def (@defs) {
+               die "cannot specify transparent for $def"
+                   if $nc eq '-' && !grep { $_ eq $def } qw(l);
                if ($def eq '*') {
                    $colourmap{$_}=$nc foreach keys %colourmap;
                } elsif (exists $colourmap{$def}) {
@@ -1763,9 +1767,11 @@ dv("cmd__do $ctx @al ",'$ctx',$ctx);
                   "      sx5 neg  0             moveto\n".
                   "      sx5 neg  $lmu_txtboxh  lineto\n".
                   "      sx5      $lmu_txtboxh  lineto\n".
-                  "      sx5      0             lineto closepath\n".
-                  "      gsave  ".set_colour(1, 'l')." fill  grestore\n".
-                  "      $lmu_txtboxlw setlinewidth stroke\n".
+                  "      sx5      0             lineto closepath\n");
+               if ($colourmap{'l'} ne '-') {
+                   ol("      gsave  ".set_colour(1, 'l')." fill  grestore\n");
+               }
+               ol("      $lmu_txtboxlw setlinewidth stroke\n".
                   "      sx5 neg $lmu_txtboxpadx add  $lmu_txtboxtxty\n".
                   "      moveto s show\n");
            }