From 09e6c63f4182d01afaa4d6ec56354346f5aa078a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 2 Mar 2019 08:39:36 +0000 Subject: [PATCH] support for L3, although it doesn't work --- Parse.pm | 5 +++-- generate-board | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Parse.pm b/Parse.pm index 147ecd3..6bd3047 100644 --- a/Parse.pm +++ b/Parse.pm @@ -42,7 +42,7 @@ sub read_in () { $ccolour = $&; next; } - if (my ($name, $water) = m{^\t(\S.*\w|L2?)(?: \[(\d+)\])?$}) { + if (my ($name, $water) = m{^\t(\S.*\w|L\d?)(?: \[(\d+)\])?$}) { confess unless defined $ccolour; my $dname = $c{DisplayNames}{$name} // $name; $name =~ s{/}{}g; @@ -59,7 +59,7 @@ sub read_in () { $cregion = $name; next; } - if (my ($aref, $adikes) = m{^\t\t(\S.*[A-Za-z.]|L2?)(?: (\+\+?))?$}) { + if (my ($aref, $adikes) = m{^\t\t(\S.*[A-Za-z.]|L\d?)(?: (\+\+?))?$}) { my $adj = { Dikes => (length $adikes // 0), L => $. }; if ($aref =~ m{\.}) { $adj->{Pattern} = $aref; @@ -109,6 +109,7 @@ sub unique_aref ($$) { sub region_cmp { ($a eq 'L' ) <=> ($b eq 'L' ) or ($a eq 'L2') <=> ($b eq 'L2') or + ($a eq 'L3') <=> ($b eq 'L3') or ($a eq 'NZ') <=> ($b eq 'NZ') or $a cmp $b } diff --git a/generate-board b/generate-board index deed43f..b3f3fd6 100755 --- a/generate-board +++ b/generate-board @@ -41,7 +41,7 @@ our $sre = qr{(?:(\")|(?=\w))(.*)\1$}; # 2 captures, $2 is the name sub prs2r ($) { # bodgery for the sea and land - return 'NZ' if m/ \| / && !grep { !m{^(?:NZ|L2?)$} } split / \| /, $_[0]; + return 'NZ' if m/ \| / && !grep { !m{^(?:NZ|L\d?)$} } split / \| /, $_[0]; $prs2region{$_[0]} // confess "@_ ?" } sub prs2rr ($) { $region{prs2r($_[0])} } @@ -68,7 +68,7 @@ sub read_faces () { my $last_ai; if ($rr->{Name} eq 'NZ') { # We combined L and NZ; now we must split them again - # in fact, we just throw away L and L2 entirely. + # in fact, we just throw away L* entirely. # Here, when processing NZ, we keep only vertices that # are part of NZ. @edges = grep { @@ -126,7 +126,7 @@ sub read_faces () { } $process_rr->(); - $region{$_}{Special} = 1 foreach qw(NZ L L2); + $region{$_}{Special} = 1 foreach qw(NZ L L2 L3); } #----- geometry mangling ----- @@ -310,7 +310,7 @@ sub facepscolour ($) { sub fill_faces() { o("clippath ", facepscolour('land'), " fill\n"); foreach my $rr (values %region) { - next if $rr->{Name} =~ m/^L2?$/; + next if $rr->{Name} =~ m/^L\d?$/; face_path($rr); o(" ", facepscolour($rr->{Colour}), " eofill\n"); } @@ -319,7 +319,7 @@ sub fill_faces() { sub some_edge_faces (@) { o("5 setlinewidth 1 setlinejoin 0 setgray\n"); foreach my $rr (@_) { - next if $rr->{Name} =~ m/^L2?$/; + next if $rr->{Name} =~ m/^L\d?$/; face_path($rr); o(" stroke\n"); } @@ -348,7 +348,7 @@ sub edge_faces() { some_edge_faces($region{'NZ'}); afsluitdijk(); some_edge_faces(grep { - $_->{Name} !~ m{^(?:L2?|NZ|ZZ)$} + $_->{Name} !~ m{^(?:L\d?|NZ|ZZ)$} } values %region); } -- 2.30.2