chiark / gitweb /
distort-stl: debugging PS output, incomplete
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 25 Nov 2018 12:52:01 +0000 (12:52 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 25 Nov 2018 12:52:28 +0000 (12:52 +0000)
Not all that useful because typically it's off the screen or
something.  And there is no showpage.  At least, in my current test
case it produces a file which looks blank in gv.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
distort-stl

index 68b7e28d79fa731b05cb6d9205319ab8b819db57..1f177dc507f80affa8083f8307e0832737b5aa53 100755 (executable)
@@ -32,6 +32,12 @@ use Data::Dumper;
 
 sub TAU () { M_PI * 2; }
 
+my $ps = %ENV{DISTORT_PS};
+if ($ps) {
+    open PS, "> $ps" or die $!;
+    print PS "%!\n";
+}
+
 our $fa = 10;
 
 our $triangles;
@@ -47,6 +53,20 @@ sub shift_arg () {
 sub sprintf_triangle ($) {
     my ($t) = @_;
 
+    if ($ps && $t->[3] =~ m/$ENV{DISTORT_PS_RE}/) {
+       printf PS <<'END',
+ %20.16g %20.16g %20.16g moveto
+ %20.16g %20.16g %20.16g lineto
+ %20.16g %20.16g %20.16g lineto
+ closepath stroke
+END
+               $t->[0][0], $t->[0][1], $t->[0][2],
+               $t->[1][0], $t->[1][1], $t->[1][2],
+               $t->[2][0], $t->[2][1], $t->[2][2],
+               or die $!;
+       flush PS or die $!;
+    }
+
     sprintf
        "%11.6f,%11.6f,%11.6f / ".
        "%11.6f,%11.6f,%11.6f / ".