#include #include using namespace std; /* Flag of Dominincan Republic. Download, compile, and run it like this: cd wget https://markmeretzky.com/fordham/1600/src/if/dominican.C compile dominican dominican | /usr/bin/pnmtopng > public_html/dominican.png Then point your web browser at https://storm.cis.fordham.edu/~jsmith/dominican.png */ #include #include #include using namespace std; int main() { const int miny = -120; const int maxy = 120; const int minx = -130; const int maxx = 130; const int nrows = maxy - miny + 1; const int ncols = maxx - minx + 1; const int cross_full = (nrows + 4) / 5; const int half_thick = cross_full / 2; const int blueR = 0, blueG = 45, blueB = 98; const int redR = 206, redG = 17, redB = 38; const int wR = 255, wG = 255, wB = 255; cout << "P3\n" << ncols << " " << nrows << "\n" << 255 << "\n"; for (int y = maxy; y >= miny; --y) { for (int x = minx; x <= maxx; ++x) { if (std::abs(x) <= half_thick || std::abs(y) <= half_thick) { cout << wR << ' ' << wG << ' ' << wB << '\n'; continue; } if (y > 0 && x < 0) { cout << blueR << ' ' << blueG << ' ' << blueB << '\n'; } else if (y > 0 && x > 0) { cout << redR << ' ' << redG << ' ' << redB << '\n'; } else if (y < 0 && x < 0) { cout << redR << ' ' << redG << ' ' << redB << '\n'; } else { // y < 0 && x > 0 cout << blueR << ' ' << blueG << ' ' << blueB << '\n'; } } } return EXIT_SUCCESS; }