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;
112 last if %cellmap && !m/\S/;
122 my @chrs = split / /, $_;
123 <DATA> !~ m/\S/ or die;
124 foreach my $row (reverse 0..4) {
135 foreach my $chr (@chrs) {
136 s{^ }{} or die "$chr $_ ?";
137 foreach my $col (0..2) {
141 my $f = $cellmap{$&};
143 $f =~ s/\b\d/ sprintf '%05d', $col*2000 + $&*1025 /ge;
144 $f =~ s/\d\b/ sprintf '%05d', $row*2000 + $&*1025 /ge;
145 push @{ $chrpolys{$chr} }, [ split / /, $f ];
157 foreach my $chr (sort keys %chrpolys) {
158 my $mod = chrmodname $chr;
159 p "module $mod () {\n";
160 foreach my $poly (@{ $chrpolys{$chr} }) {
163 foreach my $pt (@$poly) {
165 $pt =~ s{\d{5}}{$&,};
166 $pt =~ s{\b\d}{$&.}g;
175 @demo = reverse $demo =~ m{.{1,$democols}}go;
180 gentextmodule('FontDemo', @demo);
194 /#\ r /#\ ##\ # # ### // ### /#\ /#\
195 # # /# # # # # # # # # # # #
196 # # # /#/ ##< \## ##\ ##\ // >#< \##
197 # # # # # # # # # # # # #
198 \#/ /#\ ### ##/ # ##/ \#/ # \#/ ##/
204 /## ##\ # /## #r# ###
206 \## ##/ \## \## \#/ #