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(.4)
19 # module Commitid_Form()
23 # function Commitid_pixelsz() // $Commitid_pixelsz * $Commitid_scale
24 # function Commitid_depth() // see above
26 # We can generate these forms:
34 # git rev-list --first-parent --count HEAD
35 # typically 3-4 characters but we allow for up to 6
42 # same but in two lines eg
56 # git-rev-list --first-parent --count HEAD
62 sub p { print @_ or die $!; }
65 // *** AUTOGENERATED - DO NOT EDIT *** //
66 function Commitid_pixelsz() =
67 ($Commitid_pixelsz ? $Commitid_pixelsz : 0.4) *
68 ($Commitid_scale ? $Commitid_scale : 1.0);
69 function Commitid_depth() =
70 ($Commitid_depth ? $Commitid_depth : Commitid_pixelsz()) *
71 ($Commitid_depth_scale ? $Commitid_depth_scale : 1.0);
72 function Commitid__scale() =
73 Commitid_pixelsz() / 0.1;
78 my $chrx = sprintf '%#x', ord $chr;
79 return "Commitid__chr_$chrx";
82 sub gentextmodule ($@) {
83 my ($modulename, @lines) = @_;
84 p "module $modulename(){\n";
85 p " scale(Commitid__scale()){\n";
87 foreach my $line (@lines) {
90 foreach my $chr (split //, $line) {
91 next if $chr !~ m/\S/;
92 p sprintf " translate([%d * 0.8, %d * 1.2]) %s();\n",
93 $x, $y, chrmodname $chr;
107 last if %cellmap && !m/\S/;
117 my @chrs = split / /, $_;
118 <DATA> !~ m/\S/ or die;
119 foreach my $row (reverse 0..4) {
130 foreach my $chr (@chrs) {
131 s{^ }{} or die "$chr $_ ?";
132 foreach my $col (0..2) {
136 my $f = $cellmap{$&};
138 $f =~ s/\b\d/ sprintf '%05d', $col*2000 + $&*1025 /ge;
139 $f =~ s/\d\b/ sprintf '%05d', $row*2000 + $&*1025 /ge;
140 push @{ $chrpolys{$chr} }, [ split / /, $f ];
152 foreach my $chr (sort keys %chrpolys) {
153 my $mod = chrmodname $chr;
154 p "module $mod () {\n";
155 foreach my $poly (@{ $chrpolys{$chr} }) {
158 foreach my $pt (@$poly) {
160 $pt =~ s{\d{5}}{$&,};
161 $pt =~ s{\b\d}{$&.}g;
170 @demo = reverse $demo =~ m{.{1,$democols}}go;
175 gentextmodule('Commitid_FontDemo_2D', @demo);
189 /#\ r /#\ ##\ # # ### // ### /#\ /#\
190 # # /# # # # # # # # # # # #
191 # # # /#/ ##< \## ##\ ##\ // >#< \##
192 # # # # # # # # # # # # #
193 \#/ /#\ ### ##/ # ##/ \#/ # \#/ ##/
199 /## ##\ # /## #r# ###
201 \## ##/ \## \## \#/ #