chiark / gitweb /
commitid: Provide for Holes (nfc)
[reprap-play.git] / commitid.scad.pl
index f07bdeb12fb9e33030e4b495043d4a830c21d0cb..bbc750ef5ed6ba4c724cfa603dbbc134b146f21a 100755 (executable)
@@ -386,6 +386,7 @@ sub parsefont () {
     my %chrpolys;
     # $chrs{$chr}[$poly] = $poly
     # $poly->{E} = [ "012345012345", ... ]
+    # $poly->{Holes} = $poly2
     while (<DATA>) {
        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";