chiark / gitweb /
wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Jul 2022 12:11:01 +0000 (13:11 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Jul 2022 12:11:01 +0000 (13:11 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
overflow-tube.ps.pl

index 0aff68b83e451991ee2ab168bf2564d35265ee74..5b08f86d664a654340914365e89bbdedefcd3351 100755 (executable)
@@ -23,44 +23,69 @@ my $y_cut = 120; # XX
 my $y_top = 160; # XX
 my $y_cutd = 20;
 
+my $spacing = 23;
+my $colspacing = 24;
+my $vhalf = sqrt( $spacing ** 2 - ($colspacing*0.5) ** 2 );
+
 o <<END;
 gsave
 0.5 setgray
 
 /cut_line {
+                              newpath
   $x_cut 0                    moveto
   $x_cut $y_cut               lineto
   0      $y_cut $y_cutd add   lineto
   0      $y_top               lineto
-  stroke
+                              stroke
 } def
 
 cut_line
 END
 
-sub places {
+sub places ($) {
+  my ($repi) = @_;
   my $data = <<END;
-       -1 -1   34 14
-       -H  H   34 14 *
+       -1 -1
+       -1  0   34 14
+       -H  V   34 14 *
         0  0   34 15
         0 -1   35 15
         0 -2   35 16
-        H -2-H 35 16 *
+        H -2-V 35 16 *
         1 -2   36 16
         1 -1   37 16
+        1  0
 END
+  my @line_poses;
   foreach (split /\n/, $data) {
     s{\#.*}{};
     next unless m/\S/;
     s{^\s*}{};
-    s{H}{ sqrt(2) }eg;
+    s{H}{ -0.5 }g;
+    s{V}{ $vhalf / $spacing }ge;
     s{\*}{1}eg;
     my ($x,$y,$money,$veeps,$ruby) = map { eval $_ } split /\s+/;
     $ruby ||= 0;
-    print STDERR "DATA $x $y $money $veeps $ruby\n";
+    $x *= $colspacing;
+    $y *= $spacing;
+
+    push @line_poses, "$x $y";
+    next unless defined $money;
+
+    $money += 4 * $repi;
+    $veeps += 2 * $repi;
+
+    o <<END;
+% place $x $y $money $veeps $ruby
+gsave
+  $x $y translate
+  
+grestore
+END
   }
 }
 
-places();
+places(0);
 
 print $ps_framing or die $!;