From 8707feb16d5e63e5314ab749c98d45f85e18d3b0 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 14 Feb 2016 23:25:52 +0000 Subject: [PATCH] commitid: Provide for Holes (nfc) Allow a polygon to have a Holes, which is a list of edges. Positive/negative recursivion is supported by the data structure but not by the output code, which simply ignores them. Currenlty nothing makes holes so this is a no-op. --- commitid.scad.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/commitid.scad.pl b/commitid.scad.pl index f07bdeb..bbc750e 100755 --- a/commitid.scad.pl +++ b/commitid.scad.pl @@ -386,6 +386,7 @@ sub parsefont () { my %chrpolys; # $chrs{$chr}[$poly] = $poly # $poly->{E} = [ "012345012345", ... ] + # $poly->{Holes} = $poly2 while () { next unless m/\S/; chomp; @@ -425,14 +426,26 @@ sub parsefont () { my $demo = ''; my $democols = 6; foreach my $chr (sort keys %chrpolys) { + my $polys = $chrpolys{$chr}; + $_->{Holes} = [] foreach @$polys; + my $mod = chrmodname $chr; p "module $mod () {\n"; foreach my $poly (@$polys) { p " polygon("; + my $holes = $poly->{Holes}; my (@points, @vecs); p_edgelist(\@points, \@vecs, $poly->{E}); + foreach my $hole (@$holes) { + p_edgelist(\@points, \@vecs, $hole->{E}); + } p "points=[".(join ",",@points)."],"; + if (@$holes) { + p ",paths=[".(join ",", + map { "[".(join ",",@$_)."]" } + @vecs)."],"; + } p "convexity=4);\n"; } p "}\n"; -- 2.30.2