chiark / gitweb /
bb and page construction confusion fixes
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 7 Mar 2019 17:27:12 +0000 (17:27 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 7 Mar 2019 17:27:12 +0000 (17:27 +0000)
generate-board

index f5ad7364c01f7e089788eebfff030d8ceefa01cb..69c2b1526379f52fedba9ce17413431f877f226c 100755 (executable)
@@ -345,27 +345,24 @@ sub computeboundings() {
                         @{ $bb{PrintableT} }[2..3],
                        ];
   } elsif ($maxpaper =~ m/^a1/) {
+    my $offx = 0.5*($a1_w - $bb{Entire}[2]);
+    my $offy = 0.5*($a1_h - $bb{Entire}[3]);
+    $somepage->('P', -$offx,-$offy, $a1_w-$offx, $a1_h-$offy);
     my $hairs = 30 * MM2PT;
     my $hairsw = $bb{Entire}[2];
     my $hairsh = $bb{Entire}[3];
     my $surround = 5 * MM2PT;
     my $surroundw = $bb{Entire}[2] + $surround*2;
     my $surroundh = $bb{Entire}[3] + $surround*2;
-    $somepage->('P', 0,0, $a1_w, $a1_h);
-    my $offx = 0.5*($bb{PageP}[2] - $bb{Entire}[2]);
-    my $offy = 0.5*($bb{PageP}[3] - $bb{Entire}[3]);
     my @hrect = @{ $bb{Entire} };
-    $bb{Entire}[0] += $offx;  $bb{Entire}[1] += $offy;
-    $bb{Entire}[2] += $offx;  $bb{Entire}[3] += $offy;
     if ($maxpaper eq 'a1m') {
       @hrect = @{ $submargins->($a1m_pasteedge, \@hrect) };
-      $bb{Cutout} = $submargins->($a1m_pasteedge, $bb{Entire});
+      $bb{Cutout} = \@hrect;
     }
     my $w_stroke = $xopts =~ m/W/ ?
        ' gsave 3 setlinewidth stroke grestore '
        : '';
     $preamble_from_boundings = <<END;
-        $offx $offy translate
          1 setlinewidth
          0 setgray
          /a1hairs {
@@ -380,6 +377,7 @@ sub computeboundings() {
          $hrect[0] $hrect[3] a1hairs
          $hrect[2] $hrect[3] a1hairs
          $hrect[2] $hrect[1] a1hairs
+         newpath
          -$surround -$surround moveto
           $surroundw 0         rlineto
           0 $surroundh         rlineto
@@ -396,6 +394,8 @@ END
 sub showboundings () {
   return unless $xopts =~ m/B/;
   o("  grestore gsave\n");
+  my $bb = $bb{$bounding};
+  o("  $bb->[0] neg $bb->[1] neg translate\n");
   my $i = 0;
   my $on = 2;
   my $off = 9;
@@ -424,7 +424,7 @@ sub o_amble (@) {
   $t =~ s/^\&+/ '%' x length $& /mge;
   o($t);
 }
-      
+
 sub preamble() {
   my $bb = $bb{$bounding}; confess $bounding unless $bb;
   my $sz = [ $bb->[2] - $bb->[0], $bb->[3] - $bb->[1] ];
@@ -440,13 +440,14 @@ sub preamble() {
 /board {
   gsave
   $bb->[0] neg  $bb->[1] neg  translate
-$preamble_from_boundings
+  $preamble_from_boundings
+
+  % adjustment to actual image placement within prinable areas etc.:
   34 -15 translate
 END
   if ($maxpaper eq 'a4') {
     o("0 -17 translate\n");
   }
-  # xxx split into pages
 }
 
 sub postamble () {