chiark / gitweb /
costs
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 3 Dec 2020 15:34:01 +0000 (15:34 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 3 Dec 2020 15:34:01 +0000 (15:34 +0000)
pumpkin-books.ps.pl

index 6f430ace6e4d6194faac0a00564fe175c1a48bea..6c1f552ad1e78e76501bfa00dcee83a8e578234c 100755 (executable)
@@ -2,6 +2,8 @@
 
 use strict;
 
+our $black = '0 0 0 1 setcmykcolor';
+
 my $green = ["1 0 1 0", "0 0 0 0"];
 
 sub chip ($$) {
@@ -32,8 +34,8 @@ END
   $o;
 }
 
-sub general_book ($) {
-  my ($this) = @_;
+sub general_book ($$) {
+  my ($this, $costs) = @_;
   my $o = <<END;
 %!
 
@@ -42,7 +44,7 @@ sub general_book ($) {
 90 rotate
 10 10 translate
 
-0 0 0 1 setcmykcolor
+$black
 1 setlinewidth
 
 /tw 57.5 def
@@ -53,6 +55,10 @@ sub general_book ($) {
 /chip 15 def
 /spot 3.5 def
 
+/costtexth 0.215 def
+/costtextsz 12 def
+/costtextdx -0.03 def
+/costfont /Heletica-BoldOblique findfont costtextsz scalefont def
 
 tw  0  translate
 
@@ -93,12 +99,20 @@ newpath
 END
 
   foreach my $costi (0..2) {
+    my $cost = $costs->[$costi];
     my $pips = qw(1 2 4)[$costi];
     $o .= <<END
+  costfont setfont
+  -2.5 $costi add 3 div
 gsave
-  -2.5 $costi add 3 div costcirch dc translate
+  dup costcirch dc translate
   ${\ chip($this,$pips) }
 grestore
+  costtexth exch costtextdx add exch dc moveto
+  $black
+  ($cost)
+  dup stringwidth pop  -0.5 mul  costtextsz neg  rmoveto
+  show
 END
   }
 
@@ -106,7 +120,7 @@ END
 }
   
 sub green_book () {
-  general_book($green);
+  general_book($green, [qw(5 9 15)]);
 }
 
 print green_book() or die $!;