chiark / gitweb /
green book done
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 3 Dec 2020 16:13:09 +0000 (16:13 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 3 Dec 2020 16:13:09 +0000 (16:13 +0000)
pumpkin-books.ps.pl

index 7b1aedc974606fce42304718fb747f36a1d9c0ee..46e2d3be6737d6b51f325300dd481f1e030b1bf2 100755 (executable)
@@ -48,6 +48,28 @@ sub ruby () { # put in gsave translate
 END
 }
 
+sub exposition ($) {
+  my ($text) = @_;
+  my $fontsz = 6;
+  my $o = <<END;
+    /Times-Roman findfont $fontsz scalefont setfont $black
+END
+  $text =~ s/\s+$//;
+  my @lines = split /\n/, $text;
+  foreach my $y (0..$#lines) {
+    my $l = $lines[$y];
+    $l =~ s/[()\\]/\\$&/g;
+    my $yd = $fontsz * (0.5*@lines - $y);
+    $o .= <<END;
+    0 0.70 dc moveto
+    0 $yd rmoveto
+    ($l)  dup stringwidth pop -0.5 mul 0 rmoveto
+    show
+END
+  }
+  $o;
+}
+
 sub general_book ($$) {
   my ($this, $costs) = @_;
   my $o = <<END;
@@ -58,9 +80,6 @@ sub general_book ($$) {
 90 rotate
 10 10 translate
 
-$black
-1 setlinewidth
-
 /tw 57.5 def
 /th 73 def
 /bdiag 5 def
@@ -88,6 +107,15 @@ tw  0  translate
     exch                 % x y
 } def
 
+3 setlinewidth
+0 0 0 0.2 setcmykcolor
+newpath
+0 0 dc moveto
+0 1 dc lineto stroke
+
+$black
+1 setlinewidth
+
 newpath
 -1 0  dc moveto
 +1 0  dc lineto
@@ -97,7 +125,8 @@ closepath stroke
 
 newpath
 0 0 dc         moveto
-0 1 dc rlineto stroke
+0 thirdlineh dc rlineto
+-1 thirdlineh dc lineto stroke
 
 /thirddivline {               % xprop
   newpath
@@ -109,9 +138,6 @@ newpath
 1 thirddivline
 2 thirddivline
 
-newpath
--1 thirdlineh dc moveto
-0 thirdlineh dc lineto stroke
 END
 
   foreach my $costi (0..2) {
@@ -157,6 +183,13 @@ gsave
   0.85 0.275 dc translate
   ${\ ruby() }
 grestore
+END
+
+  $o .= exposition(<<END);
+For each pumpkin in the last 3 chips,
+but not more than the number of
+green chips in your pot,
+receive 1 ruby.
 END
 
   $o;