From 2e65ab3d2c506385e04f9219755780dfe11bb69f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 20 Oct 2017 19:47:57 +0100 Subject: [PATCH] poster-tube-lid-parametric: support reversed sections --- poster-tube-lid-parametric.pl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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; -- 2.30.2