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
|
/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;
/*
* Font tests; draws all 32 combinations of five attributes:
*
* label_color: (Neutral: cols 1, 3; Red, cols 2, 4)
* label_mask: (Neutral: cols 1, 2; Yellow: cols 3, 4)
*
* label_border color: (Neutral: odd rows, Blue otherwise)
* label_border width: (0pt: rows 1-2, 5-6, 1pt otherwise)
*
* pad: (0pt: rows 1-4, 1pt otherwise)
*/
// test objects
void objs()
{
label(P(-0.5,0), "The");
masklabel(P(0.5,0), "The");
}
// attribute-setting commands on bool flags
void label_color(bool arg)
{
if (arg)
label_color(Red());
else
label_color(Neutral());
}
void label_mask(bool arg)
{
if (arg)
label_mask(Yellow(0.3));
else
label_mask(Neutral());
}
void set_border(bool col, std::string len)
{
if (col)
label_border(Blue(1.2), len);
else
label_border(Neutral(), len);
}
void label_border(bool col, bool wid)
{
if (wid)
set_border(col, "1pt");
else
set_border(col, "0pt");
}
void pad(bool arg)
{
if (arg)
label_pad("6pt");
else
label_pad("0pt");
}
// 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");
backing(Black(0.1));
pen(Black(0.3));
grid(8,8);
label_color(tf(i0));
label_mask(tf(i1));
label_border(tf(i2),tf(i3));
pad(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();
}
|