home *** CD-ROM | disk | FTP | other *** search
- /* :set tabstops=4 */
- static char *RCSid = "$Header: alpha_plot.c,v 1.1 86/04/20 16:16:28 sysad Exp $";
-
- /*
- * $Log: alpha_plot.c,v $
- * Revision 1.1 86/04/20 16:16:28 sysad
- * Initial distribution version
- *
- *
- */
-
-
- /* It is the intent of the author that this software may be distributed
- * and used freely, without restriction. If you make improvements or
- * enhancements, I would appreciate a copy.
- *
- * Duane H. Hesser Teltone Corporation
- * ....uw-beaver!tikal!sysad
- * ....uw-beaver!tikal!dhh
- */
-
- /* Character table for generation of ascii characters.
- * Each row represents one character. A nine high by eight wide
- * matrix is used, including two descenders. The first byte of
- * each row is the "width" of the character; the remaining bytes
- * are the bit pattern of the character, starting with the
- * descenders (table[x][3] is the lower left corner of the character,
- * which references the starting location of the character).
- *
- * Characters generated by lplot are rather severely restricted
- * by the low dot density; as a result, labels will usually be
- * "longer" in plotted length than those produced by other filters.
- * The "width" includes the separation of the character from any
- * following character (starting location of current character +
- * width of current character = starting location of following
- * character). This is used to improve the appearance of labels,
- * and reduce the problem of label size expansion.
- */
- #include "extern.h"
-
- char table[][10] = {
- 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ' ' */
- 6, 0, 0, 040, 0, 040, 040, 040, 040, 040, /* '!' */
- 5, 0, 0, 0, 0, 0, 0, 0, 0120, 0120, /* '"' */
- 7, 0, 0, 0120, 0120, 0370, 0120, 0370, 0120, 0120, /* '#' */
- 9, 0, 0, 020, 0374, 022, 0174, 0220, 0176, 020, /* '$' */
- 9, 0, 0, 0204, 0112, 044, 020, 0110, 0244, 0102, /* '%' */
- 8, 0, 0, 0144, 0230, 0220, 0250, 0104, 0240, 0100, /* '&' */
- 3, 0, 0, 0, 0, 0, 0, 0200, 0100, 0100, /* ''' */
- 5, 0, 0, 040, 0100, 0200, 0200, 0200, 0100, 040, /* '(' */
- 5, 0, 0, 0200, 0100, 040, 040, 040, 0100, 0200, /* ')' */
- 7, 0, 0, 0250, 0160, 0330, 0160, 0250, 0, 0, /* '*' */
- 7, 0, 0, 040, 040, 0370, 040, 040, 0, 0, /* '+' */
- 4, 0200, 0100, 0100, 0, 0, 0, 0, 0, 0, /* ',' */
- 7, 0, 0, 0, 0, 0, 0370, 0, 0, 0, /* '-' */
- 3, 0, 0, 0200, 0, 0, 0, 0, 0, 0, /* '.' */
- 9, 0, 0, 0200, 0100, 040, 020, 010, 04, 02, /* '/' */
- 9, 0, 0, 070, 0104, 0202, 0202, 0202, 0104, 070, /* '0' */
- 6, 0, 0, 0160, 0040, 0040, 0040, 0040, 0140, 0040, /* '1' */
- 8, 0, 0, 0374, 0200, 0160, 010, 04, 0204, 0170, /* '2' */
- 8, 0, 0, 0170, 0204, 04, 070, 04, 0204, 0170, /* '3' */
- 8, 0, 0, 010, 010, 0374, 0210, 0110, 050, 010, /* '4' */
- 8, 0, 0, 0160, 0210, 04, 010, 0360, 0200, 0370, /* '5' */
- 8, 0, 0, 0170, 0204, 0204, 0370, 0100, 040, 020, /* '6' */
- 8, 0, 0, 0100, 0100, 0100, 040, 020, 010, 0374, /* '7' */
- 9, 0, 0, 070, 0104, 0202, 0104, 070, 0104, 070, /* '8' */
- 8, 0, 0, 040, 020, 010, 0170, 0204, 0204, 0170, /* '9' */
- 4, 0, 0, 0, 0300, 0, 0, 0300, 0, 0, /* ':' */
- 5, 0, 0200, 0100, 0140, 0, 0140, 0, 0, 0, /* ';' */
- 6, 0, 0, 020, 040, 0100, 0200, 0100, 040, 020, /* '<' */
- 7, 0, 0, 0, 0, 0370, 0, 0370, 0, 0, /* '=' */
- 6, 0, 0, 0200, 0100, 040, 020, 040, 0100, 0200, /* '>' */
- 8, 0, 0, 040, 0, 040, 020, 010, 0204, 0170, /* '?' */
- 10, 0, 0, 076, 0100, 0236, 0245, 0231, 0102, 074, /* '@' */
- 9, 0, 0, 0202, 0202, 0376, 0202, 0104, 050, 020, /* 'A' */
- 8, 0, 0, 0370, 0204, 0204, 0370, 0204, 0204, 0370, /* 'B' */
- 8, 0, 0, 0170, 0204, 0200, 0200, 0200, 0204, 0170, /* 'C' */
- 8, 0, 0, 0370, 0204, 0204, 0204, 0204, 0204, 0370, /* 'D' */
- 8, 0, 0, 0374, 0200, 0200, 0360, 0200, 0200, 0374, /* 'E' */
- 8, 0, 0, 0200, 0200, 0200, 0360, 0200, 0200, 0374, /* 'F' */
- 8, 0, 0, 0170, 0204, 0204, 0214, 0200, 0204, 0170, /* 'G' */
- 8, 0, 0, 0204, 0204, 0204, 0374, 0204, 0204, 0204, /* 'H' */
- 5, 0, 0, 0340, 0100, 0100, 0100, 0100, 0100, 0340, /* 'I' */
- 7, 0, 0, 0140, 0220, 020, 020, 020, 020, 070, /* 'J' */
- 8, 0, 0, 0204, 0210, 0220, 0340, 0220, 0210, 0204, /* 'K' */
- 8, 0, 0, 0374, 0200, 0200, 0200, 0200, 0200, 0200, /* 'L' */
- 9, 0, 0, 0202, 0202, 0202, 0222, 0252, 0306, 0202, /* 'M' */
- 9, 0, 0, 0202, 0206, 0212, 0222, 0242, 0302, 0202, /* 'N' */
- 8, 0, 0, 0170, 0204, 0204, 0204, 0204, 0204, 0170, /* 'O' */
- 8, 0, 0, 0200, 0200, 0200, 0370, 0204, 0204, 0370, /* 'P' */
- 8, 0, 0, 064, 0110, 0224, 0204, 0204, 0110, 060, /* 'Q' */
- 8, 0, 0, 0204, 0210, 0220, 0370, 0204, 0204, 0370, /* 'R' */
- 8, 0, 0, 0170, 0204, 04, 0170, 0200, 0204, 0170, /* 'S' */
- 6, 0, 0, 040, 040, 040, 040, 040, 040, 0370, /* 'T' */
- 9, 0, 0, 070, 0104, 0202, 0202, 0202, 0202, 0202, /* 'U' */
- 9, 0, 0, 020, 050, 0104, 0202, 0202, 0202, 0202, /* 'V' */
- 9, 0, 0, 0202, 0306, 0252, 0222, 0202, 0202, 0202, /* 'W' */
- 9, 0, 0, 0202, 0104, 050, 020, 050, 0104, 0202, /* 'X' */
- 9, 0, 0, 020, 020, 020, 020, 050, 0104, 0202, /* 'Y' */
- 8, 0, 0, 0374, 0200, 0100, 040, 020, 010, 0374, /* 'Z' */
- 5, 0, 0, 0340, 0200, 0200, 0200, 0200, 0200, 0340, /* '[' */
- 9, 0, 0, 02, 04, 010, 020, 040, 0100, 0200, /* '\' */
- 5, 0, 0, 0340, 040, 040, 040, 040, 040, 0340, /* ']' */
- 6, 0, 0, 0, 0, 0, 0, 0210, 0120, 040, /* '^' */
- 8, 0, 0377, 0, 0, 0, 0, 0, 0, 0, /* '_' */
- 4, 0, 0, 0, 0, 0, 0, 040, 040, 0100, /* '`' */
- 8, 0, 0, 0164, 0210, 0170, 010, 0360, 0, 0, /* 'a' */
- 7, 0, 0, 0360, 0210, 0210, 0210, 0360, 0200, 0200, /* 'b' */
- 7, 0, 0, 0170, 0200, 0200, 0200, 0170, 0, 0, /* 'c' */
- 8, 0, 0, 0164, 0210, 0210, 0210, 0170, 010, 010, /* 'd' */
- 8, 0, 0, 0170, 0200, 0370, 0204, 0170, 0, 0, /* 'e' */
- 6, 0, 0, 0100, 0100, 0100, 0340, 0100, 0110, 060, /* 'f' */
- 7, 0360, 010, 0170, 0210, 0210, 0210, 0160, 0, 0, /* 'g' */
- 7, 0, 0, 0210, 0210, 0210, 0210, 0360, 0200, 0200, /* 'h' */
- 5, 0, 0, 0340, 0100, 0100, 0100, 0300, 0, 0100, /* 'i' */
- 7, 0140, 0220, 020, 020, 020, 020, 020, 0, 020, /* 'j' */
- 7, 0, 0, 0210, 0220, 0240, 0300, 0240, 0220, 0200, /* 'k' */
- 5, 0, 0, 0340, 0100, 0100, 0100, 0100, 0100, 0300, /* 'l' */
- 9, 0, 0, 0222, 0222, 0222, 0222, 0356, 0, 0, /* 'm' */
- 8, 0, 0, 0104, 0104, 0104, 0104, 0270, 0, 0, /* 'n' */
- 7, 0, 0, 0160, 0210, 0210, 0210, 0160, 0, 0, /* 'o' */
- 7, 0200, 0200, 0360, 0210, 0210, 0210, 0360, 0, 0, /* 'p' */
- 7, 010, 010, 0170, 0210, 0210, 0210, 0170, 0, 0, /* 'q' */
- 6, 0, 0, 0200, 0200, 0200, 0310, 0260, 0, 0, /* 'r' */
- 7, 0, 0, 0360, 010, 0160, 0200, 0170, 0, 0, /* 's' */
- 7, 0, 0, 020, 050, 040, 040, 0370, 040, 040, /* 't' */
- 8, 0, 0, 0164, 0210, 0210, 0210, 0210, 0, 0, /* 'u' */
- 8, 0, 0, 040, 0120, 0210, 0210, 0210, 0, 0, /* 'v' */
- 9, 0, 0, 0104, 0252, 0222, 0222, 0202, 0, 0, /* 'w' */
- 8, 0, 0, 0210, 0120, 040, 0120, 0210, 0, 0, /* 'x' */
- 8, 0360, 010, 0170, 0210, 0210, 0210, 0210, 0, 0, /* 'y' */
- 8, 0, 0, 0370, 0100, 040, 020, 0370, 0, 0, /* 'z' */
- 6, 0, 0, 060, 0100, 0100, 0200, 0100, 0100, 060, /* '{' */
- 3, 0, 0, 0200, 0200, 0200, 0, 0200, 0200, 0200, /* '|' */
- 7, 0, 0, 0300, 040, 040, 020, 040, 040, 0300, /* '}' */
- 7, 0, 0, 0, 0, 0, 0, 020, 0250, 0100, /* '~' */
- 7, 0, 0, 040, 0160, 0250, 040, 040, 0, 0, /* 'd' */
- };
-
- alpha_plot(c)
- char c;
- {
- int width;
- int index = c - ' ';
- char *ptr;
- short x,y,i,j;
-
- if((index < 0) || (index >= sizeof(table))) return;
-
- ptr = table[index];
- width = ((int)*ptr++ & 0377);
-
- /* Move so that the character is plotted with its center (approx)
- * is plotted at the current point. We have to undo this at the
- * end.
- */
- curxdot -= 3;
- curydot -= 3;
- /* this is a hack--character height changes due to different
- * dot densities in x and y. we restore this at the end.
- */
- if(Rotate) --curydot;
-
- for(i = 0;i < 9; ++i)
- {
- if(ptr[i])
- {
- for(j = 0; j < 8; ++j)
- {
- if(plotbit(ptr[i],j))
- {
- x = curxdot + 7 - j;
- y = curydot + i - 2;
- point(x,y);
- }
- }
- }
- }
- if(Rotate)
- {
- /* different dot densities, again */
- width = (double)width * YPERINCH / XPERINCH;
- curydot++; /* end hack */
- }
- curx += (double)width/mapxfac;
- curxdot += 3;
- curydot += 3;
- curxdot += width;
- }
-