@@ -116,8 +116,9 @@ begin
116116 bordercolor (unset) eq { ctx /default_bordercolor 2 copy known {get /bordercolor exch def} {pop pop} ifelse } if
117117 } { pop } ifelse
118118
119+ %
119120 % Input validation
120-
121+ %
121122 textxalign (unset) ne {
122123 //renmatrix.xalignopts textxalign known not {
123124 /bwipp.renmatrixBadTextxalign (textxalign must be offleft, left, center, right or offright) //raiseerror exec
@@ -178,8 +179,10 @@ begin
178179 /left {dir 4 ne {x y dir cput [x y]} if /x x 1 sub def /dir 4 def} def
179180 /up {dir 8 ne {x y dir cput [x y]} if /y y 1 sub def /dir 8 def} def
180181
182+ %
183+ % Walk the outline of a region emitting edge coordinates of the path
184+ %
181185 /trace {
182- % Walk the outline of a region emitting edge coordinates of the path
183186 /y exch def /x exch def
184187 % dir 1:right 2:down 4:left 8:up
185188 /dir x 1 add y 1 add xyget 1 eq {8} {4} ifelse def
@@ -206,7 +209,9 @@ begin
206209
207210 } def
208211
212+ %
209213 % Set RGB or CMYK color, or some other color by name
214+ %
210215 /setanycolor {
211216 /anycolor exch def
212217 anycolor length 1 lt {
@@ -244,7 +249,9 @@ begin
244249 } if
245250 } def
246251
252+ %
247253 % Plot a layer of single colour
254+ %
248255 /drawlayer {
249256
250257 /pixsorig pixs def
@@ -263,10 +270,14 @@ begin
263270 /pixx pixx 2 add def
264271 /pixy pixy 2 add def
265272
273+ %
266274 % Cache of visited corners for each direction
275+ %
267276 /cache [ pixs length {0} repeat ] def
268277
278+ %
269279 % Construct paths by tracing regions avoiding duplication by using the cache
280+ %
270281 /paths [
271282 0 1 pixy 2 sub {
272283 /j exch def
@@ -287,11 +298,15 @@ begin
287298 } for
288299 ] def
289300
301+ %
290302 % Revert the bitmap size
303+ %
291304 /pixx pixx 2 sub def
292305 /pixy pixy 2 sub def
293306
307+ %
294308 % Draw the image
309+ %
295310 newpath
296311 paths {
297312 /p exch def
@@ -346,10 +361,14 @@ begin
346361 /inkspreadh inkspreadh 2 div def
347362 /inkspreadv inkspreadv 2 div def
348363
364+ %
349365 % Force symbol to given width
366+ %
350367 width pixx div 72 mul height pixy div 72 mul scale
351368
369+ %
352370 % Display the border and background
371+ %
353372 showborder {
354373 /tl [ borderleft borderwidth 2 div add neg pixy bordertop add borderwidth 2 div add ] def
355374 /tr [ pixx borderright add borderwidth 2 div add pixy bordertop add borderwidth 2 div add ] def
@@ -375,7 +394,9 @@ begin
375394 grestore
376395 } if
377396
397+ %
378398 % Display the matrix
399+ %
379400 colormap (unset) eq {
380401 /colormap << 1 barcolor >> def
381402 } if
@@ -388,7 +409,9 @@ begin
388409 ] dotty {drawlayerdots} {drawlayer} ifelse
389410 } forall
390411
412+ %
391413 % Display the text
414+ %
392415 //rendertext exec
393416
394417 grestore
0 commit comments