From: Ian Jackson Date: Fri, 20 Oct 2017 18:47:57 +0000 (+0100) Subject: poster-tube-lid-parametric: support reversed sections X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=2e65ab3d2c506385e04f9219755780dfe11bb69f;p=reprap-play.git poster-tube-lid-parametric: support reversed sections --- diff --git a/poster-tube-lid-parametric.pl b/poster-tube-lid-parametric.pl index 64a6003..68a0ed3 100755 --- a/poster-tube-lid-parametric.pl +++ b/poster-tube-lid-parametric.pl @@ -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;