chiark / gitweb /
commitid.scad.pl: Generate 2D name inside gentextmodule; docs
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 5 Feb 2016 03:23:53 +0000 (03:23 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 5 Feb 2016 03:23:53 +0000 (03:23 +0000)
commitid.scad.pl

index 892ed7efa531b773d437bab4bfd303492b73304a..fbf1231597968fa1cd5bd2de847f2a8992956148 100755 (executable)
@@ -15,8 +15,12 @@ $SIG{__WARN__} = sub { die @_; };
 #
 # For each form we have
 #
-#    module Commitid_Form_2D(.4)
-#    module Commitid_Form()
+#    module Commitid_Form_2D() { ... }
+#    module Commitid_Form() { ... }
+#
+#  These have their origin in the bottom left corner.  The 3D model
+#  is a positive, has its origin halfway through, and is twice the
+#  depth in height, so it can be added or subtracted.
 #
 # And we provide
 #
@@ -80,8 +84,9 @@ sub chrmodname ($) {
 }
 
 sub gentextmodule ($@) {
-    my ($modulename, @lines) = @_;
-    p "module $modulename(){\n";
+    my ($form, @lines) = @_;
+    my $modb = "Commitid_$form";
+    p "module ${modb}_2D(){\n";
     p " scale(Commitid__scale()){\n";
     my $y = @lines;
     foreach my $line (@lines) {
@@ -172,7 +177,7 @@ sub parsefont () {
 
 parsefont();
 
-gentextmodule('Commitid_FontDemo_2D', @demo);
+gentextmodule('FontDemo', @demo);
 
 __DATA__