-
Notifications
You must be signed in to change notification settings - Fork 0
/
flag.ps
230 lines (194 loc) · 4.67 KB
/
flag.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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
%!PS-Adobe-3.0
% Texas flag.
% https://github.com/srl295/txflag.git
% Copyright © 2020 by Steven R. Loomis
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
% http://www.apache.org/licenses/LICENSE-2.0
/in {72 mul} def
/GRAY { 0.1 setgray } def
/BLUE { 0.25 setgray 0 0.12549019607843137 0.3568627450980392 setrgbcolor } def
/RED { 0.75 setgray 191 256 div 13 256 div 62 256 div setrgbcolor} def
/WHITE { 1.0 setgray 1 1 1 setrgbcolor } def
/height 3 in def
/width 3 2 div height mul def
/inset 1 in def
% add text
/Helvetica findfont 0.1 in scalefont setfont
3 in 0.5 in moveto
(https://github.com/srl295/txflag.git) show
% number of points
/starpt 5 def
% 0 = no depth (polygon). 1 = starfish.
% This is the multiplied against (𝜃/2) to calculate the outside angle of the star's "cut in"
/stardepth 1 def
% set this to 1 for debug or 0 for no debug
% shows the legally specified circle of reference, plus shows a polygon behind the star (in red)
/DEBUG 0 def
% Internal Defs
% blue width
/bwid width 3 div def
% half blue width
/hbwid bwid 2 div def
% half-height
/hheight height 2 div def
% white width - twice the blue width
/wwid bwid 2 mul def
% now the star
/starwidth width 3 div .75 mul def
/hstarwidth starwidth 2 div def
% interior angle of nominal polygon
/theta 360 starpt div def
% 𝜃 = 360°/starpt
% edge of nominal polygon
/ell
starwidth 2 div
theta 2 div sin
mul 2 mul def
% lengt of each edge =
% l = 2r × sin (𝜃/2)
% where r = 2w
% gamma is the "cut in" angle
/gamma theta 2 div stardepth mul def
% m is the length of the single cut-in line
/emm
ell 2 div
gamma cos
mul def
DEBUG {
gsave
0 setgray
gsave
1 in height 2 mul translate
0.5 setlinewidth
0 0 moveto 1 in 0 rlineto stroke
2 setlinewidth
theta neg rotate
newpath
0 0 moveto
% 0 1 inch rlineto 0 .5 inch neg rlineto
ell 0 rlineto
% 0 1 inch rlineto 0 .5 inch neg rlineto
stroke
grestore
gsave
4 in height 2 mul translate
0.5 setlinewidth
0 0 moveto 1 in 0 rlineto stroke
2 setlinewidth
gamma neg rotate
newpath
0 0 moveto
% 0 1 inch rlineto 0 .5 inch neg rlineto
emm 0 rlineto
% 0 1 inch rlineto 0 .5 inch neg rlineto
stroke
grestore
grestore
} repeat
% ----- begin
% box
inset inset translate
% /gray 0.5 0.5 0.5 setcolor def
% blue
BLUE
0 0 moveto
bwid 0 rlineto
0 height rlineto
bwid neg 0 rlineto
0 height neg rlineto
fill
% WHITE
WHITE
% .9 setgray % TEST
bwid hheight moveto
wwid 0 rlineto
0 hheight rlineto
wwid neg 0 rlineto
0 hheight neg rlineto
fill
RED
bwid 0 moveto
wwid 0 rlineto
0 hheight rlineto
wwid neg 0 rlineto
0 hheight neg rlineto
fill
% DEBUG: red polygon under the star
DEBUG {
RED
gsave
bwid 2 div
height 2 div
translate
% -45 rotate % DEBUG
newpath
0 hstarwidth moveto
theta 2 div rotate
starpt {
% currentpoint starwidth 10 div 0 360 arc
currentpoint translate
theta neg rotate
ell 0 rlineto
% % 0 starwidth 2 div starwidth 10 div 0 360 arc
% % stroke
% % starwidth 5 div starwidth 2 div neg rlineto
% 0 0 moveto 360 starpt div rotate
% 0 starwidth 2 div lineto
} repeat
% closepath
fill
grestore
} repeat % END debug
% the actual star!
WHITE
% GRAY
gsave
hbwid
hheight
translate
% -45 rotate % DEBUG
newpath
0 hstarwidth moveto
% gamma rotate
% -90 rotate
theta neg rotate
theta 90 sub rotate
starpt
starpt {
currentpoint translate
gamma 2 div neg rotate
emm 2.5 mul 0 rlineto % why 2.5?
90 gamma 2 div sub rotate
emm 2.5 mul 0 rlineto % why 2.5?
theta 270 sub rotate
} repeat
% closepath
fill
grestore
DEBUG {
% now the star's circle for ref
gsave
GRAY
3 setlinewidth
[ 1 3 ] 2 setdash
0 1 0 setrgbcolor % green
newpath
hbwid
hheight
starwidth 2 div
0 360 arc
stroke
grestore
} repeat % end DEBUG
% gray (outer box)
GRAY
0 0 moveto
0 height rlineto
width 0 rlineto
0 height neg rlineto
width neg 0 rlineto
stroke
showpage