chiark / gitweb /
commitid.scad.pl: Provide %s_sz
[reprap-play.git] / commitid.scad.pl
index de1efa87586485c334880cd624607565d332ede4..e7aee601745ce94cfde957a4b9a11ab2d9909cbb 100755 (executable)
@@ -90,6 +90,7 @@ sub gentextmodule ($@) {
     p "module ${modb}_2D(){\n";
     p " scale(Commitid__scale()){\n";
     my $y = @lines;
+    my $cols = 1;
     foreach my $line (@lines) {
        $y--;
        my $x = 0;
@@ -99,6 +100,7 @@ sub gentextmodule ($@) {
                $x, $y, chrmodname $chr;
            $x++;
        }
+       $cols = $x if $x > $cols;
     }
     p " }\n";
     p "}\n";
@@ -106,6 +108,8 @@ sub gentextmodule ($@) {
     p " d=Commitid_depth();\n";
     p " translate([0,0,-d]) linear_extrude(height=d*2) ${modb}_2D();\n";
     p "}\n";
+    p sprintf "function %s_sz() = Commitid__scale() * 0.1 * [ %d, %d ];\n",
+       $modb, 2 * (@lines * 6 - 1), 2 * ($cols * 4 - 1);
 }
 
 our @demo;