chiark / gitweb /
commitid-cube-test: debug echos
[reprap-play.git] / commitid.scad.pl
index aced30a46fa7dfbbb2d45b81c6fb27cb80737063..de1efa87586485c334880cd624607565d332ede4 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
 #
@@ -33,6 +37,7 @@ $SIG{__WARN__} = sub { die @_; };
 #   Tiny8:
 #       git rev-list --first-parent --count HEAD
 #       typically 3-4 characters but we allow for up to 6
+#       padded with zeroes; if too long we reduce mod 10^n
 #       eg
 #            Tiny4    1070
 #
@@ -43,10 +48,10 @@ $SIG{__WARN__} = sub { die @_; };
 #            Tiny4Q   10
 #                     70
 #
-#   Git4
-#   Git6
-#   Git8
-#       git-rev-parse HEAD
+#   Git4  Git4Q
+#   Git6  Git6Q
+#   Git8  Git8Q
+#       git-rev-parse HEAD   (prefix of requested length)
 #       eg
 #            Git6    82f2a2
 
@@ -80,8 +85,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) {
@@ -96,6 +102,10 @@ sub gentextmodule ($@) {
     }
     p " }\n";
     p "}\n";
+    p "module ${modb}(){\n";
+    p " d=Commitid_depth();\n";
+    p " translate([0,0,-d]) linear_extrude(height=d*2) ${modb}_2D();\n";
+    p "}\n";
 }
 
 our @demo;
@@ -172,7 +182,7 @@ sub parsefont () {
 
 parsefont();
 
-gentextmodule('Commitid_FontDemo', @demo);
+gentextmodule('FontDemo', @demo);
 
 __DATA__