3232% IN THE SOFTWARE.
3333
3434% --BEGIN RENDERER renmaximatrix--
35- % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor--
35+ % --REQUIRES preamble raiseerror setuphooks processoptions setanycolor render --
3636currentglobal
3737true setglobal
3838/setpacking where {pop currentpacking true setpacking} if
39392 dict
4040dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
4141dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4242dup /setanycolor dup /uk.co.terryburton.bwipp findresource put
43+ dup /render dup /uk.co.terryburton.bwipp findresource put
4344begin
4445/renmaximatrix {
4546
5960 /bordertop 0.0 def
6061 /borderbottom 0.0 def
6162 /borderwidth 0.5 def
63+ /gridfit false def
64+ /griddpi 0 def
6265
6366 {def} forall
6467 opt currentdict /opt undef /apply //processoptions exec /options exch def
6972 backgroundcolor (unset) eq { ctx /default_backgroundcolor 2 copy known {get /backgroundcolor exch def} {pop pop} ifelse } if
7073 bordercolor (unset) eq { ctx /default_bordercolor 2 copy known {get /bordercolor exch def} {pop pop} ifelse } if
7174 inkspread null eq { ctx /default_inkspread 2 copy known {get /inkspread exch def} {pop pop} ifelse } if
75+ griddpi 0 eq { ctx /default_griddpi 2 copy known {get /griddpi exch def} {pop pop} ifelse } if
7276 } { pop } ifelse
7377
78+ % Auto-enable gridfit when griddpi is specified
79+ griddpi 0 ne { /gridfit true def } if
80+
7481 inkspread null eq {/inkspread 0.15 def} if
7582
7683 inkspread -1 lt inkspread 1 gt or {
@@ -97,6 +104,10 @@ begin
97104 /bwipp.renmaximatrixBadBorderwidth (borderwidth must be from 0 to 10) //raiseerror exec
98105 } if
99106
107+ griddpi 0 ne { griddpi 30 lt griddpi 9600 gt or {
108+ /bwipp.renmaximatrixBadGriddpi (griddpi must be 0 or from 30 to 9600) //raiseerror exec
109+ } if } if
110+
100111 options /debughexagons known
101112 /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse
102113 and { /bwipp.debughexagons pixs //raiseerror exec } if
@@ -107,6 +118,11 @@ begin
107118
108119 2.4945 dup scale % from 1pt to 0.88mm
109120
121+ %
122+ % Grid fit: uniform even-pixel snap preserves hex aspect ratio
123+ %
124+ gridfit { 2 false /gridfit //render exec } if
125+
110126 %
111127 % Display the border and background
112128 %
0 commit comments