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
|
/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;
/*
* Line and fill style test; draws all 32 combinations of five attributes:
*
* line color: (Neutral: cols 1, 3; Red, cols 2, 4)
* line style: (Solid: cols 1, 2; dashed: cols 3, 4)
*
* base color: (Neutral: odd rows, Blue otherwise)
* base width: (1pt: rows 1-2, 5-6, 4pt otherwise)
*
* fill color: (Neutral: rows 1-4, Yellow otherwise)
*/
// test objects
void objs()
{
rect(P(0,0), P(1,1));
line(P(-1,-1), P(1,-1));
}
// attribute-setting commands on bool flags
void line_color(bool arg)
{
if (arg)
pen(Red(), 2);
else
pen(Neutral(), 2);
}
void line_style(bool arg)
{
if (arg)
dashed();
}
void base_color(bool col, double wid)
{
if (col)
base(Blue(1.2), wid);
else
base(Neutral(), wid);
}
void base_pen(bool col, bool wid)
{
if (wid)
base_color(col, 4);
else
base_color(col, 1);
}
void fill_color(bool arg)
{
if (arg)
fill(Yellow());
else
fill(Neutral());
}
// we'll use 0, 1 as loop indices; convert to bool
bool tf(int i)
{
return i == 0 ? false : true;
}
// where to position the result of a test
P loc(int i0, int i1, int i2, int i3, int i4)
{
double horiz(0), vert(7);
if (tf(i0))
horiz += 1;
if (tf(i1))
horiz += 2;
if (tf(i2))
vert -= 1;
if(tf(i3))
vert -= 2;
if (tf(i4))
vert -= 4;
return P(horiz, vert);
}
int main()
{
picture(P(0,0), P(4,8), "6 x 9in");
begin();
// the tests proper
for (int i0=0; i0<2; ++i0)
for (int i1=0; i1<2; ++i1)
for (int i2=0; i2<2; ++i2)
for (int i3=0; i3<2; ++i3)
for (int i4=0; i4<2; ++i4)
{
screen scr(P(-1,-1), P(1,1));
activate(scr);
solid(); // may need to reset line style
border(Green(0.6), "0.1pt");
line_color(tf(i0));
line_style(tf(i1));
base_pen(tf(i2),tf(i3));
fill_color(tf(i4));
objs();
scr.scale(0.9);
inset(loc(i0,i1,i2,i3,i4), loc(i0,i1,i2,i3,i4) + P(1,1));
deactivate(scr);
}
end();
}
|