chiark / gitweb /
poster-tube-lid-parametric: support reversed sections
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 20 Oct 2017 18:47:57 +0000 (19:47 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 20 Oct 2017 18:47:57 +0000 (19:47 +0100)
poster-tube-lid-parametric.pl

index 64a6003..68a0ed3 100755 (executable)
@@ -128,17 +128,22 @@ sub point ($$$$) {
 }
 
 sub get_sections_ptvals {
-    my $last_name;
+    my $last_ptval;
     my @out;
     while (my $name = shift @_) {
        if ($name eq '-') {
-           push @out, [ $last_name, 1.0 ];
+           push @out, $last_ptval;
        } else {
            my $count = shift @_;
+           my $neg = sub { $_[0] };
+           if ($count < 0) {
+               $count = -$count;
+               $neg = sub { 1- $_[0] };
+           }
            foreach (my $ix = 0; $ix < $count; $ix++) {
-               push @out, [ $name, $ix/$count ];
+               push @out, [ $name, $neg->($ix/$count) ];
            }
-           $last_name = $name;
+           $last_ptval = [ $name, $neg->(1.0) ];
        }
     }
     return @out;