/* gencolor.c */ /* a small program to generate a web page that demonstrates all of the non-dithering web colors, plus monochrome color charts for reference */ /* Written by Tom Strong (strong@dementia.org), June, 1999 */ #include #include void header(void); void footer(void); void chip(int r, int g, int b); void caption(int r, int g, int b); void chart(void); void refs(void); void conv(void); void ref(int r, int g, int b, char * tag); int main(void) { header(); chart(); refs(); conv(); footer(); return(0); } void conv(void) { int i; printf("
\n

Hex Conversion Chart

\n"); printf("
\n\n"); for (i = 0; i <= 0xFF; i += 0x11) { printf("\n", i, i); } printf("
%02x%03d
\n
\n"); return; } void ref(int r, int g, int b, char * tag) { int i, j; printf("
\n

%s Reference Chart

\n", tag); printf("\n"); for (i = 0; i <= 0xFF; i += 0x44) { printf(" \n"); for (j = i; j <= i + 0x33; j += 0x11) { chip((r != 0) ? j : 0, (g != 0) ? j : 0, (b != 0) ? j : 0); } printf(" \n"); printf(" \n"); for (j = i; j <= i + 0x33; j += 0x11) { caption((r != 0) ? j : 0, (g != 0) ? j : 0, (b != 0) ? j : 0); } printf(" \n"); } printf("
\n
\n"); return; } void refs(void) { printf("

Monochrome Charts for Reference

\n"); printf("
Many of these colors are not web-safe. " "These charts are included for comparison only.
\n"); ref(1, 0, 0, "Red"); ref(0, 1, 0, "Green"); ref(0, 0, 1, "Blue"); ref(1, 1, 1, "Gray"); return; } void chart(void) { int r, g, b; for (r = 0; r <= 0xFF; r += 0x33) { printf("
\n

Red = %02x (%03d)

\n", r, r); printf("\n"); for (g = 0; g <= 0xFF; g += 0x33) { printf(" \n"); for (b = 0; b <= 0xFF; b += 0x33) { chip(r, g, b); } printf(" \n"); printf(" \n"); for (b = 0; b <= 0xFF; b += 0x33) { caption(r, g, b); } printf(" \n"); } printf("
\n
\n"); } return; } void header(void) { printf("\n"); printf("\n"); printf("\n"); printf("RGB Web-Safe Color Chart\n"); printf("\n"); printf("\n"); printf("

RGB Web-Safe Colors

\n"); printf("
\n"); printf("These are the colors that should safely display under\n"); printf("any web browser, with the possible exception of Lynx.\n"); printf("
\n"); printf("They are listed in six tables, " "each table having a constant red value.\n"); return; } void footer(void) { printf("
\n"); printf("This is the program used to create this file\n", __FILE__); printf("
\n"); printf("This page is maintained by " "Tom Strong\n"); printf("\n"); printf("\n"); return; } void chip(int r, int g, int b) { printf(" xxx\n", r, g, b, r, g, b); return; } void caption(int r, int g, int b) { printf(" #%02x%02x%02x\n", r, g, b); return; } /* EOF */