chiark / gitweb /
poster-tube-lid-parametric: bugfix
[reprap-play.git] / poster-tube-lid-parametric.pl
index 64a6003a51efe2c9e565d3cb79861542a0b4c84c..d538a29f58d09c19d815cfceef97704f4802f2c9 100755 (executable)
@@ -24,7 +24,7 @@ my $sine_height = 6;
 my $ballend_xr = $thick/2;
 
 my @i_sections = qw(ball0   6
-                   sine0  10
+                   sine0  -10
                    lin0    2
                    circle 20
                    lin1    2
@@ -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;