blob: 2bb00012aa4d1481f1b8a275bb854088855bc79d (
plain) (
blame)
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
|
###############################################################################
# #
# Lout @Pie package for drawing pie charts #
# Version 1.0 (October 2002) #
# Jeffrey H. Kingston #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either Version 3, or (at your option) #
# any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307 USA #
# #
# As a special exception, when this file is read by Lout when processing #
# a Lout source document, you may use the result without restriction. #
# #
###############################################################################
@SysPrependGraphic { pief.lpg }
@SysInclude { lengths } # @PSLengths and @LoutLengths
@SysInclude { coltex } # @ColourCommand and @TextureCommand
###############################################################################
# #
# @PieSetup symbol #
# #
###############################################################################
export @Pie
def @PieSetup
named save { no }
named totalweight { 100 }
named radius { 2.5c }
import @PSLengths named initialangle{ 0d }
named leftextra { 0i }
named rightextra { 0i }
named aboveextra { 0i }
named belowextra { 0i }
named leftcaption { }
named rightcaption { }
named abovecaption { }
named belowcaption { }
named leftgap { 0.5c }
named rightgap { 0.5c }
named abovegap { 0.5c }
named belowgap { 0.5c }
named hidecaptions { yes }
named weight { 1 }
named paint { none }
import @TextureImport named texture { solid }
named outlinestyle
named solid { "/lpiesolid" }
named dashed { "/lpiedashed" }
named cdashed { "/lpiecdashed" }
named dotted { "/lpiedotted" }
named noline { "/lpienoline" }
{ solid }
import @PSLengths named outlinedashlength { 0.2f }
import @PSLengths named outlinewidth
named thin { 0.04f }
named medium { 0.08f }
named thick { 0.12f }
{ thin }
named detach
named yes Yes { 0.5 }
named no No { 0.0 }
{ no }
named label { }
named labelfont { -2p }
named labelbreak { clines }
named labelmargin { 0.2f }
named labelformat right @Body { @Body }
named labelradius
named internal { 0.6 }
named external { 1.4 }
{ internal }
import @PSLengths named labeladjust { 0 0 }
named finger { no }
named fingerstyle
named solid { "/lpiesolid" }
named dashed { "/lpiedashed" }
named cdashed { "/lpiecdashed" }
named dotted { "/lpiedotted" }
named noline { "/lpienoline" }
{ solid }
import @PSLengths named fingerdashlength { 0.2f }
import @PSLengths named fingerwidth
named thin { 0.04f }
named medium { 0.08f }
named thick { 0.12f }
{ thin }
named fingerradius { 0.7 }
import @PSLengths named fingeradjust{ 0 0 }
named fingerarrow { no }
import @PSLengths named fingerarrowlength { 0.6f }
import @PSLengths named fingerarrowwidth { 0.45f }
{
###########################################################################
# #
# @Pie symbol #
# #
###########################################################################
export @Slice
def @Pie
named save { save }
named totalweight { totalweight }
named radius { radius }
import @PSLengths named initialangle { initialangle }
named leftextra { leftextra }
named rightextra { rightextra }
named aboveextra { aboveextra }
named belowextra { belowextra }
named leftcaption { leftcaption }
named rightcaption { rightcaption }
named abovecaption { abovecaption }
named belowcaption { belowcaption }
named leftgap { leftgap }
named rightgap { rightgap }
named abovegap { abovegap }
named belowgap { belowgap }
named hidecaptions { hidecaptions }
named weight { weight }
named paint { paint }
import @TextureImport named texture { texture }
named outlinestyle
named solid { "/lpiesolid" }
named dashed { "/lpiedashed" }
named cdashed { "/lpiecdashed" }
named dotted { "/lpiedotted" }
named noline { "/lpienoline" }
{ outlinestyle }
import @PSLengths named outlinedashlength{ outlinedashlength }
import @PSLengths named outlinewidth
named thin { 0.04f }
named medium { 0.08f }
named thick { 0.12f }
{ outlinewidth }
named detach
named yes Yes { 0.5 }
named no No { 0.0 }
{ detach }
named label { label }
named labelfont { labelfont }
named labelbreak { labelbreak }
named labelmargin { labelmargin }
named labelformat right @Body { labelformat @Body }
named labelradius
named internal { 0.6 }
named external { 1.4 }
{ labelradius }
import @PSLengths named labeladjust { labeladjust }
named finger { finger }
named fingerstyle
named solid { "/lpiesolid" }
named dashed { "/lpiedashed" }
named cdashed { "/lpiecdashed" }
named dotted { "/lpiedotted" }
named noline { "/lpienoline" }
{ fingerstyle }
import @PSLengths named fingerdashlength{ fingerdashlength }
import @PSLengths named fingerwidth
named thin { 0.04f }
named medium { 0.08f }
named thick { 0.12f }
{ fingerwidth }
named fingerradius { fingerradius }
import @PSLengths named fingeradjust { fingeradjust }
named fingerarrow { fingerarrow }
import @PSLengths named fingerarrowlength { fingerarrowlength }
import @PSLengths named fingerarrowwidth { fingerarrowwidth }
body @Body
{
#######################################################################
# #
# Miscellaneous helper definitions #
# #
#######################################################################
def @AddPaint left col right texture
{
col @Case {
{ "no" "none" "nopaint" } @Yield "{}"
else @Yield { "{" @ColourCommand col texture "fill }" }
}
}
# Like @Graphic, but affects the graphics state of right parameter
def @InnerGraphic
left ps
right x
{
{ ps gsave // grestore } @Graphic x
}
def @ZeroWidth right x
{
@HContract @VContract {
^|0io @HContract @VContract x |0io
}
}
def @ZeroSize right x
{
@HContract @VContract {
^/0io ^|0io @HContract @VContract x |0io /0io
}
}
#######################################################################
# #
# @Slice #
# #
#######################################################################
def @Slice
named weight { weight }
named paint { paint }
import @TextureImport named texture { texture }
named outlinestyle
named solid { "/lpiesolid" }
named dashed { "/lpiedashed" }
named cdashed { "/lpiecdashed" }
named dotted { "/lpiedotted" }
named noline { "/lpienoline" }
{ outlinestyle }
import @PSLengths named outlinedashlength { outlinedashlength }
import @PSLengths named outlinewidth
named thin { 0.04f }
named medium { 0.08f }
named thick { 0.12f }
{ outlinewidth }
named detach
named yes Yes { 0.5 }
named no No { 0.0 }
{ detach }
named label { label }
named labelfont { labelfont }
named labelbreak { labelbreak }
named labelmargin { labelmargin }
named labelformat right @Body { labelformat @Body }
named labelradius
named internal { 0.6 }
named external { 1.4 }
{ labelradius }
import @PSLengths named labeladjust { labeladjust }
named finger { finger }
named fingerstyle
named solid { "/lpiesolid" }
named dashed { "/lpiedashed" }
named cdashed { "/lpiecdashed" }
named dotted { "/lpiedotted" }
named noline { "/lpienoline" }
{ fingerstyle }
import @PSLengths named fingerdashlength { fingerdashlength }
import @PSLengths named fingerwidth
named thin { 0.04 ft }
named medium { 0.08 ft }
named thick { 0.12 ft }
{ fingerwidth }
named fingerradius { fingerradius }
import @PSLengths named fingeradjust{ fingeradjust }
named fingerarrow { fingerarrow }
import @PSLengths named fingerarrowlength { fingerarrowlength }
import @PSLengths named fingerarrowwidth { fingerarrowwidth }
{
def @DrawSlice
{
outlinedashlength "[" outlinestyle "]"
outlinewidth paint @AddPaint texture
weight detach
"lpiebeginslice"
//
"lpieendslice"
}
def @TranslateLabelAndDrawFinger
{ labeladjust labelradius "lpietranslatelabel"
finger @Case {
{ no No } @Yield ""
{ yes Yes } @Yield {
fingerdashlength "[" fingerstyle "]"
fingerwidth fingeradjust fingerradius
"lpiedrawfinger"
fingerarrow @Case {
{ no No } @Yield ""
{ yes Yes } @Yield {
fingerarrowlength fingerarrowwidth
"lpiedrawarrowhead"
}
}
}
}
}
def @AddMargins right x
{
@HContract @VContract {
//labelmargin ||labelmargin x ||labelmargin //labelmargin
}
}
@Null @ZeroSize @DrawSlice @Graphic
@TranslateLabelAndDrawFinger @InnerGraphic {
@AddMargins labelfont @Font labelbreak @Break labelformat label
} @Null
}
def @Above
{
abovecaption @Case {
"" @Yield ""
else @Yield @OneCol {
||0.5rt clines @Break abovecaption || //abovegap
}
}
}
def @Below
{
belowcaption @Case {
"" @Yield ""
else @Yield @OneCol {
//belowgap ||0.5rt clines @Break belowcaption ||
}
}
}
def @Left
{
leftcaption @Case {
"" @Yield ""
else @Yield @OneRow {
{ //0.5rt clines @Break leftcaption // } ^||leftgap
}
}
}
def @Right
{
rightcaption @Case {
"" @Yield ""
else @Yield @OneRow {
||rightgap { //0.5rt lines @Break rightcaption // }
}
}
}
def @HideWidth right x
{
hidecaptions @Case {
{ No no } @Yield x
{ Yes yes } @Yield @OneCol { ||0io x ||0io }
}
}
def @AddCaptions right x
{
@HContract @VContract
{
| @Above |
/ @HideWidth @Left | &0.5rt x | @HideWidth @Right
/ | @Below |
}
}
def @AddExtra right x
{
@HContract @VContract
{
/aboveextra |leftextra x |rightextra /belowextra
}
}
def @GraphicSetup right x
{
{
save @Case {
{ yes Yes } @Yield {
"grestore save gsave" totalweight initialangle "lpiebegin"
//
"lpieend restore"
}
{ no No } @Yield {
totalweight initialangle "lpiebegin"
//
"lpieend"
}
}
} @Graphic x
}
def @Base right x
{
def @Square { radius @Wide radius @High {} }
@HContract @VContract {
@Square ^| @Square
^/
@Square | @Square
/
x
}
}
@AddCaptions @AddExtra @GraphicSetup @Base @Body
}
}
|