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 function Commitid_pixelsz() =
66 ($Commitid_pixelsz ? $Commitid_pixelsz : 0.4) *
67 ($Commitid_scale ? $Commitid_scale : 1.0);
68 function Commitid_depth() =
69 ($Commitid_depth ? $Commitid_depth : Commitid_pixelsz()) *
70 ($Commitid_depth_scale ? $Commitid_depth_scale : 1.0);
71 function Commitid__scale() =
72 Commitid_pixelsz() / 0.1;
79 last if %cellmap && !m/\S/;
88 my @chrs = split / /, $_;
89 <DATA> !~ m/\S/ or die;
90 foreach my $row (reverse 0..4) {
101 foreach my $chr (@chrs) {
102 s{^ }{} or die "$chr $_ ?";
103 foreach my $col (0..2) {
107 my $f = $cellmap{$&};
109 $f =~ s/\b\d/ sprintf '%05d', $col*2000 + $&*1025 /ge;
110 $f =~ s/\d\b/ sprintf '%05d', $row*2000 + $&*1025 /ge;
111 push @{ $chrpolys{$chr} }, [ split / /, $f ];
123 foreach my $chr (sort keys %chrpolys) {
124 my $chrx = sprintf '%#x', ord $chr;
125 my $mod = "Commitid__chr_$chrx";
126 p "module $mod () {\n";
127 foreach my $poly (@{ $chrpolys{$chr} }) {
130 foreach my $pt (@$poly) {
132 $pt =~ s{\d{5}}{$&,};
133 $pt =~ s{\b\d}{$&.}g;
140 my $px = @demo % $democols;
141 my $py = int(@demo / $democols);
142 push @demo, " scale( Commitid__scale() ) translate([$px * 0.800, $py * 1.200])
145 p "module Commitid_FontDemo(){\n";
150 # print Dumper(\%chrpolys);
155 #p "Commitid_FontDemo();\n";
169 /#\ r /#\ ##\ # # ### // ### /#\ /#\
170 # # /# # # # # # # # # # # #
171 # # # /#/ ##< \## ##\ ##\ // >#< \##
172 # # # # # # # # # # # # #
173 \#/ /#\ ### ##/ # ##/ \#/ # \#/ ##/
179 /## ##\ # /## #r# ###
181 \## ##/ \## \## \#/ #