4 $SIG{__WARN__} = sub { die @_; };
6 # xxx much of the comment below is TODO
8 # We generate a physical indication of which commit was used.
10 # We provide for scaling factors with dynamic variables:
11 # $Commitid_pixelsz if not set, we use 0.4 } multiplied
12 # $Commitid_scale if not set, we use 1.0 } together
13 # $Commitid_depth if not set, we use xy pixel size from above
14 # $Commitid_depth_scale if not set, we use 1.0 (multiplies depth above)
16 # For each form we have
18 # module Commitid_Form_2D() { ... }
19 # module Commitid_Form() { ... }
21 # These have their origin in the bottom left corner. The 3D model
22 # is a positive, has its origin halfway through, and is twice the
23 # depth in height, so it can be added or subtracted.
27 # function Commitid_pixelsz() // $Commitid_pixelsz * $Commitid_scale
28 # function Commitid_depth() // see above
30 # We can generate these forms:
38 # git rev-list --first-parent --count HEAD
39 # typically 3-4 characters but we allow for up to 6
46 # same but in two lines eg
60 # git-rev-list --first-parent --count HEAD
66 sub p { print @_ or die $!; }
69 // *** AUTOGENERATED - DO NOT EDIT *** //
70 function Commitid_pixelsz() =
71 ($Commitid_pixelsz ? $Commitid_pixelsz : 0.4) *
72 ($Commitid_scale ? $Commitid_scale : 1.0);
73 function Commitid_depth() =
74 ($Commitid_depth ? $Commitid_depth : Commitid_pixelsz()) *
75 ($Commitid_depth_scale ? $Commitid_depth_scale : 1.0);
76 function Commitid__scale() =
77 Commitid_pixelsz() / 0.1;
82 my $chrx = sprintf '%#x', ord $chr;
83 return "Commitid__chr_$chrx";
86 sub gentextmodule ($@) {
87 my ($form, @lines) = @_;
88 my $modb = "Commitid_$form";
89 p "module ${modb}_2D(){\n";
90 p " scale(Commitid__scale()){\n";
92 foreach my $line (@lines) {
95 foreach my $chr (split //, $line) {
96 next if $chr !~ m/\S/;
97 p sprintf " translate([%d * 0.8, %d * 1.2]) %s();\n",
98 $x, $y, chrmodname $chr;
104 p "module ${modb}(){\n";
105 p " d=Commitid_depth();\n";
106 p " translate([0,0,-d]) linear_extrude(height=d*2) ${modb}_2D();\n";
116 last if %cellmap && !m/\S/;
126 my @chrs = split / /, $_;
127 <DATA> !~ m/\S/ or die;
128 foreach my $row (reverse 0..4) {
139 foreach my $chr (@chrs) {
140 s{^ }{} or die "$chr $_ ?";
141 foreach my $col (0..2) {
145 my $f = $cellmap{$&};
147 $f =~ s/\b\d/ sprintf '%05d', $col*2000 + $&*1025 /ge;
148 $f =~ s/\d\b/ sprintf '%05d', $row*2000 + $&*1025 /ge;
149 push @{ $chrpolys{$chr} }, [ split / /, $f ];
161 foreach my $chr (sort keys %chrpolys) {
162 my $mod = chrmodname $chr;
163 p "module $mod () {\n";
164 foreach my $poly (@{ $chrpolys{$chr} }) {
167 foreach my $pt (@$poly) {
169 $pt =~ s{\d{5}}{$&,};
170 $pt =~ s{\b\d}{$&.}g;
179 @demo = reverse $demo =~ m{.{1,$democols}}go;
184 gentextmodule('FontDemo', @demo);
198 /#\ r /#\ ##\ # # ### // ### /#\ /#\
199 # # /# # # # # # # # # # # #
200 # # # /#/ ##< \## ##\ ##\ // >#< \##
201 # # # # # # # # # # # # #
202 \#/ /#\ ### ##/ # ##/ \#/ # \#/ ##/
208 /## ##\ # /## #r# ###
210 \## ##/ \## \## \#/ #