-
Notifications
You must be signed in to change notification settings - Fork 0
/
ps-template.ps
132 lines (111 loc) · 3.2 KB
/
ps-template.ps
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
% (CC-BY-SA) H.Zeller 2022-03-18
/mm { 72 25.4 div mul } def
/font-size-micron 0.15 def
/base-plate-extra 0.2 def
/cut-color { 0 0 0 } def % Standard cut. No kerf consideration needed.
/cut-color2 { 0 0 0 } def % Optional: layer to allow enforce cut sequence
/scan-color { 0 1 0 } def % scan engraving for text
/engrave-color { 0 1 1 } def % line engraving
/comment-color { 0.8 0.8 0.8 } def % Fabrication info.
/base-plate-label-color { scan-color } def % Text.
/base-plate-line-color { engrave-color } def % engraved line
/layer-label-color { comment-color } def
/bounding-box-color { 0.8 0.8 0.9 } def
% <offset-x> <offset-y> (header-text) start-page
/start-page {
/Helvetica findfont 2.2 mm scalefont setfont
layer-label-color setrgbcolor
10 mm 5 mm moveto show
stroke
10 mm 20 mm translate
% Move to chip-scale
0.001 mm display-scale mul dup scale
translate % Offset from the bounding box, so start at 0,0
/Helvetica findfont font-size-micron scalefont setfont
0.001 setlinewidth
} def
% w h radius
/rounded-corner-box {
3 dict begin
/radius exch def
/height exch def
/width exch def
currentpoint
stroke % need to flush state before gsave/grestore
gsave
translate
0 radius add 0 moveto
width radius sub 0 lineto
width radius sub 0 radius add radius -90 0 arc
width height radius sub lineto
width radius sub height radius sub radius 0 90 arc
0 radius add height lineto
0 radius add height radius sub radius 90 180 arc
0 0 radius add lineto
0 radius add 0 radius add radius 180 270 arc
closepath stroke
grestore
end
} def
% Expected: position at origin
% (txt) tick-height width hor-measure-line
/hor-measure-line {
/width exch def
/tick-height exch def
/txt exch def
/txt-width txt stringwidth pop def
0 tick-height 2 div neg rmoveto
0 tick-height rlineto
0 tick-height 2 div neg rmoveto
/half-line-len width txt-width sub 2 div def
half-line-len 0 rlineto
0 font-size-micron 3 div neg rmoveto
base-plate-label-color setrgbcolor
txt show
base-plate-line-color setrgbcolor
0 font-size-micron 3 div rmoveto
half-line-len 0 rlineto
0 tick-height 2 div neg rmoveto
0 tick-height rlineto
0 tick-height 2 div neg rmoveto
stroke
} def
/ver-measure-line {
gsave
currentpoint translate
90 rotate
hor-measure-line
grestore
} def
% <txt> <x> <y> <width> <height> <color> show-bounding-box
/show-bounding-box {
gsave
setrgbcolor
/height exch def
/width exch def
/y exch def
/x exch def
% Adding the extra margin around the box
x base-plate-extra sub y base-plate-extra sub moveto
width base-plate-extra 2 mul add
height base-plate-extra 2 mul add
base-plate-extra rounded-corner-box
base-plate-label-color setrgbcolor
x y moveto
0 font-size-micron 1 mul neg rmoveto % Vertical align
% dup stringwidth pop neg 0 rmoveto % Right align
show
grestore
} def
% <x> <y> <angle> <text> center-text
/center-text {
4 2 roll
gsave
translate
0 0 moveto
dup stringwidth pop
2 div neg font-size-micron 2 div neg rmoveto
exch rotate
show
grestore
} def