-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathrenmaximatrix.ps.src
178 lines (160 loc) · 6.81 KB
/
renmaximatrix.ps.src
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
% Barcode Writer in Pure PostScript
% https://bwipp.terryburton.co.uk
%
% Copyright (c) 2004-2024 Terry Burton
%
% $Id$
%
% Permission is hereby granted, free of charge, to any
% person obtaining a copy of this software and associated
% documentation files (the "Software"), to deal in the
% Software without restriction, including without
% limitation the rights to use, copy, modify, merge,
% publish, distribute, sublicense, and/or sell copies of
% the Software, and to permit persons to whom the Software
% is furnished to do so, subject to the following
% conditions:
%
% The above copyright notice and this permission notice
% shall be included in all copies or substantial portions
% of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
% KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
% THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
% PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
% THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
% DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
% CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
% CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
% IN THE SOFTWARE.
% --BEGIN RENDERER renmaximatrix--
% --REQUIRES preamble raiseerror processoptions--
/setpacking where {pop currentpacking true setpacking} if
10 dict
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /processoptions dup /uk.co.terryburton.bwipp findresource put
begin
/renmaximatrix {
20 dict begin
% Default options
/barcolor (unset) def
/backgroundcolor (unset) def
/bordercolor (unset) def
/inkspread 0.15 def
/showborder false def
/borderleft 0.0 def
/borderright 0.0 def
/bordertop 0.0 def
/borderbottom 0.0 def
/borderwidth 0.25 def
{def} forall
opt currentdict /opt undef //processoptions exec pop
/uk.co.terryburton.bwipp.global_ctx dup where {
exch get /ctx exch def
barcolor (unset) eq { ctx /default_barcolor 2 copy known {get /barcolor exch def} {pop pop} ifelse } if
backgroundcolor (unset) eq { ctx /default_backgroundcolor 2 copy known {get /backgroundcolor exch def} {pop pop} ifelse } if
bordercolor (unset) eq { ctx /default_bordercolor 2 copy known {get /bordercolor exch def} {pop pop} ifelse } if
} { pop } ifelse
% Set RGB or CMYK color, or some other color by name
/setanycolor {
/anycolor exch def
anycolor length 1 lt {
/bwipp.colorEnpty (Colors must not be empty) //raiseerror exec
} if
anycolor 0 get 95 ne { % RGB or CMYK
anycolor length dup 6 ne exch 8 ne and {
/bwipp.colorBadLength (Colors must be 6 or 8 hexadecimal characters or a defined name beginning with underscore) //raiseerror exec
} if
mark
0 2 anycolor length 1 sub {
anycolor exch 2 getinterval 0 exch {
dup dup 48 ge exch 57 le and {48 sub} { % 0-9
dup dup 65 ge exch 70 le and {55 sub} { % A-F
dup dup 97 ge exch 102 le and {87 sub} { % a-f
cleartomark /bwipp.colorBadCharacter (RGB and CMYK Colors must be in hexadecimal notation) //raiseerror exec
} ifelse } ifelse } ifelse
exch 16 mul add
} forall
255 div
} for
counttomark
dup 3 eq { /DeviceRGB } { /DeviceCMYK } ifelse
exch 2 add -1 roll pop % clear mark
} { % Named color beginning "_..."
/uk.co.terryburton.bwipp.global_ctx dup where {exch get} {0 dict} ifelse
/named_colors 2 copy known {get} {pop pop 0 dict} ifelse
anycolor 2 copy known not {
pop pop /bwipp.colorUnknown (Color is not defined) //raiseerror exec
} if
get mark exch aload pop counttomark 1 add -2 roll exch pop
} ifelse
{ setcolorspace setcolor } stopped {
/bwipp.colorFailedToSet (Failed to set color) //raiseerror exec
} if
} def
gsave
currentpoint translate
2.4945 dup scale % from 1pt to 0.88mm
% Display the border and background
showborder {
/tl [ borderleft borderwidth 2 div add neg 29 bordertop add borderwidth 2 div add ] def
/tr [ 30 borderright add borderwidth 2 div add 29 bordertop add borderwidth 2 div add ] def
/bl [ borderleft borderwidth 2 div add neg borderbottom borderwidth 2 div add neg ] def
/br [ 30 borderright add borderwidth 2 div add borderbottom borderwidth 2 div add neg ] def
} { % No need to extend background when there is no border
/tl [ borderleft neg inkspread add 29 bordertop add inkspread sub ] def
/tr [ 30 borderright add inkspread sub 29 bordertop add inkspread sub ] def
/bl [ borderleft neg inkspread add borderbottom neg inkspread add ] def
/br [ 30 borderright add inkspread sub borderbottom neg inkspread add ] def
} ifelse
backgroundcolor (unset) ne {
gsave
newpath bl aload pop moveto [ br tr tl ] { aload pop lineto } forall closepath
backgroundcolor setanycolor fill
grestore
} if
showborder {
gsave
newpath bl aload pop moveto [ br tr tl ] { aload pop lineto } forall closepath
bordercolor (unset) ne { bordercolor setanycolor } if
borderwidth inkspread 2 mul sub setlinewidth stroke
grestore
} if
barcolor (unset) ne { barcolor setanycolor } if
/g 0.06 inkspread add def
0.5 0.5774 translate
newpath
pixs {
dup
/x exch 30 mod def
/y exch 30 idiv def
y 2 mod 0 eq {x} {x 0.5 add} ifelse
32 y sub 0.8661 mul
moveto
0 0.5774 g sub rmoveto
-0.5 g add -0.2887 g 2 div add rlineto
0 -0.5774 g add rlineto
0.5 g sub -0.2887 g 2 div add rlineto
0.5 g sub 0.2887 g 2 div sub rlineto
0 0.5774 g sub rlineto
-0.5 g add 0.2887 g 2 div sub rlineto
closepath
} forall
fill
% Plot the locator symbol
newpath 14 13.8576 0.5774 inkspread add 0 360 arc closepath
14 13.8576 1.3359 inkspread sub 360 0 arcn closepath fill
newpath 14 13.8576 2.1058 inkspread add 0 360 arc closepath
14 13.8576 2.8644 inkspread sub 360 0 arcn closepath fill
newpath 14 13.8576 3.6229 inkspread add 0 360 arc closepath
14 13.8576 4.3814 inkspread sub 360 0 arcn closepath fill
grestore
end
}
[/barcode] {null def} forall
bind def
/renmaximatrix dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
% --END RENDERER renmaximatrix--