chiark / gitweb /
wip, can make a thing
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 28 Feb 2019 19:42:18 +0000 (19:42 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 28 Feb 2019 19:42:21 +0000 (19:42 +0000)
generate-board

index b45155cfc64518202dfaa3aef89ebba0957f8613..c467b4403c2ce1301c2cd11e4afbde5662451d28 100755 (executable)
@@ -173,7 +173,7 @@ sub transform_coordinates () {
   my $s = sin($rotateby);
   my $c = cos($rotateby);
   my $transform = Math::GSL::Matrix->new(2,2);
-  $transform->set_row(0, [  $c,  $s ]);
+  $transform->set_row(0, [  $c, -$s ]);
   $transform->set_row(1, [ -$s,  $c ]);
   print STDERR "rotate was=",prvec($dir)," theta=$theta",
       " rotateby=$rotateby s=$s c=$c\n";
@@ -182,6 +182,7 @@ sub transform_coordinates () {
     my $v = $topend ? -$GSL_DBL_MAX : $GSL_DBL_MAX;
     $lims[$topend] = Math::GSL::Vector->new([$v,$v]);
   }
+  # xxx rotation is not happening
   print STDERR "lims ",prvec($lims[0])," .. ",prvec($lims[1]),"\n";
   for_each_pos(sub {
     my ($pr) = @_;
@@ -206,6 +207,7 @@ sub transform_coordinates () {
   });
   print STDERR "lims ",prvec($lims[0])," .. ",prvec($lims[1]),"\n";
   my $translate = -$lims[0];
+  # xxx bot left doesn't seem to be 0 either; x is 0 but y is odd ?
   print STDERR "translate ",prvec($translate),"\n";
   my $scale = $c{GraphScale} * MM2PT;
   for_each_pos(sub {
@@ -215,6 +217,24 @@ sub transform_coordinates () {
   });
 }
 
+sub write_face_edges() {
+  o("5 setlinewidth\n");
+  foreach my $rr (values %region) {
+    next if $rr->{Special};
+    o("% $rr->{Name}\n");
+    # xxx setmiter?
+    o("  newpath\n");
+    my $xto = 'moveto';
+    foreach my $vertex (@{ $rr->{Polygon} }) {
+      my $pos = $vertex->{Pos};
+      # xxx break this out
+      o(sprintf "    %20.6f %20.6f %s\n", $pos->get(0),$pos->get(1), $xto);
+      $xto = 'lineto';
+    }
+    o("    closepath stroke\n");
+  }
+}
+
 #----- main program -----
 
 ($facesf, @ARGV) = @ARGV or die;
@@ -224,7 +244,11 @@ read_faces();
 calculate_centres();
 transform_coordinates();
 
-print Dumper(\%region);
+o("%!\n");
+# xxx boundingbox
+write_face_edges();
+
+#print Dumper(\%region);
 
 # Local variables:
 # cperl-indent-level: 2