--- /dev/null
+#!/usr/bin/perl -w
+use strict;
+
+our @xm = qw(4.7 6.8 10 15 22 33 47 68 100);
+our @ym = qw(3.9 5.6 8.2 12 18 27 39 56);
+
+sub p { print @_ or die $!; }
+
+p "include <commitid.scad>\n";
+p "p = Commitid_pixelsz();\n";
+
+my $x = 0;
+foreach my $xm (@xm) {
+ my $y = 0;
+ foreach my $ym (@ym) {
+ p " translate([$x,$y] * p) {\n";
+ p " difference(){\n";
+ p " translate(-0.5*p*[1,1]) square([$xm+1,$ym+1]*p);\n";
+ p " square([$xm,$ym]*p);\n";
+ p " }\n";
+ p " Commitid_BestCount_2D([$xm,$ym] * p);\n";
+ p " }\n";
+ $y += $ym + 2;
+ }
+ $x += $xm + 2;
+}
# $Commitid_scale if not set, we use 1.0 } together
# $Commitid_depth if not set, we use xy pixel size from above / 2
# $Commitid_depth_scale if not set, we use 1.0 (multiplies depth above)
+# $Commitid_max_best_scale if not set, we use 2.0 (max mult of xy in Best)
#
# For each form we have
#
sub do_some_best ($$) {
my ($modname, $formre) = @_;
- p "module Commitid_$modname(max_sz) {\n";
+ my $fullmodname = "Commitid_${modname}_2D";
+ p "module $fullmodname(max_sz) {\n";
+ p ' sc_max = $Commitid_max_best_scale ? $Commitid_max_best_scale : 2;'."\n";
+ my @do;
foreach my $f (
sort {
$b->{Chars} <=> $a->{Chars} or
}
@forms
) {
- p "// $f->{Form}\n";
+ my $form = $f->{Form};
+ p " sz_$form = Commitid_${form}_sz();\n";
+ foreach my $rot (qw(0 1)) {
+ my $id = "${form}_r${rot}";
+ p " sc_$id = min(sc_max";
+ foreach my $xy (qw(0 1)) {
+ p ",max_sz[$xy]/sz_$form","[",(($xy xor $rot)+0),"]";
+ }
+ p ");\n";
+ push @do, " if (sc_$id >= 1.0) {\n";
+ push @do, " scale(sc_$id)\n";
+ push @do, " rotate(90) translate([0,-sz_$form"."[1]])\n" if $rot;
+ push @do, " Commitid_${form}_2D();\n";
+ push @do, " } else";
+ }
}
+ push @do, <<END;
+ {
+ echo("$fullmodname could not fit anything in", max_sz);
+ }
+END
+ p $_ foreach @do;
p "}\n";
}