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 64a6003a51efe2c9e565d3cb79861542a0b4c84c..68a0ed35c219d3443e1b3a22287590c2eebebffb 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;