From 1f1a48c7ecc8938a779353150fa6a68b5da0c8ee Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 5 Feb 2016 17:58:19 +0000 Subject: [PATCH] commitid: provide 2d demo --- commitid-2d-test.scad | 3 +++ commitid.scad.pl | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 commitid-2d-test.scad diff --git a/commitid-2d-test.scad b/commitid-2d-test.scad new file mode 100644 index 0000000..a15de77 --- /dev/null +++ b/commitid-2d-test.scad @@ -0,0 +1,3 @@ +// -*- C -*- +include +Commitid_2DDemo(); diff --git a/commitid.scad.pl b/commitid.scad.pl index 33ab57d..3e813b2 100755 --- a/commitid.scad.pl +++ b/commitid.scad.pl @@ -127,6 +127,16 @@ sub chrmodname ($) { return "Commitid__chr_$chrx"; } +our $gtm_demo_i = -1; +our $gtm_demo_j; +our @gtm_demo_o; + +sub gentextmodule_demo_next_batch(){ + $gtm_demo_i++; + $gtm_demo_j = 0; +} +gentextmodule_demo_next_batch(); + sub gentextmodule ($@) { my ($form, @lines) = @_; my $modb = "Commitid_$form"; @@ -152,8 +162,14 @@ 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 * ($cols * 4 - 1), 2 * (@lines * 6 - 1); + + push @gtm_demo_o, + " translate([$gtm_demo_i * st[0], $gtm_demo_j * st[1]])". + " ${modb}_2D();\n"; + $gtm_demo_j++; } our @demo; @@ -311,6 +327,8 @@ sub do_git () { } foreach my $sz (3..10) { + gentextmodule_demo_next_batch(); + gentextmodule_plusq("Small$sz", rjustt($sz, $git_count.$git_dirty)) if defined $git_count; @@ -352,6 +370,11 @@ gentextmodule('FontDemo', @demo); do_git(); +p "module Commitid_2DDemo(){\n"; +p " st = Commitid__scale() * [ 10, 5 ];\n"; +p $_ foreach @gtm_demo_o; +p "}\n"; + flush STDOUT or die $!; close STDOUT or die $!; -- 2.30.2