home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume4 / quickplot / part2 / alpha_plot.c next >
Encoding:
C/C++ Source or Header  |  1986-11-30  |  9.1 KB  |  190 lines

  1. /* :set tabstops=4                                                    */
  2. static char *RCSid = "$Header: alpha_plot.c,v 1.1 86/04/20 16:16:28 sysad Exp $";
  3.  
  4. /*
  5.  * $Log:    alpha_plot.c,v $
  6.  * Revision 1.1  86/04/20  16:16:28  sysad
  7.  * Initial distribution version
  8.  * 
  9.  * 
  10.  */
  11.  
  12.  
  13. /* It is the intent of the author that this software may be distributed
  14.  * and used freely, without restriction.  If you make improvements or
  15.  * enhancements, I would appreciate a copy.
  16.  *
  17.  * Duane H. Hesser    Teltone Corporation
  18.  * ....uw-beaver!tikal!sysad
  19.  * ....uw-beaver!tikal!dhh
  20.  */
  21.  
  22. /* Character table for generation of ascii characters.
  23.  * Each row represents one character.  A nine high by eight wide
  24.  * matrix is used, including two descenders.  The first byte of
  25.  * each row is the "width" of the character; the remaining bytes
  26.  * are the bit pattern of the character, starting with the
  27.  * descenders (table[x][3] is the lower left corner of the character,
  28.  * which references the starting location of the character).
  29.  *
  30.  * Characters generated by lplot are rather severely restricted
  31.  * by the low dot density; as a result, labels will usually be
  32.  * "longer" in plotted length than those produced by other filters.
  33.  * The "width" includes the separation of the character from any
  34.  * following character (starting location of current character +
  35.  * width of current character = starting location of following
  36.  * character).  This is used to improve the appearance of labels,
  37.  * and reduce the problem of label size expansion.
  38.  */
  39. #include "extern.h"
  40.  
  41. char table[][10] = {
  42. 5, 0,    0,    0,    0,    0,    0,    0,    0,    0,      /* ' '   */
  43. 6, 0,    0,    040,  0,    040,  040,  040,  040,  040,    /*  '!'  */
  44. 5, 0,    0,    0,    0,    0,    0,    0,    0120, 0120,   /*  '"'  */
  45. 7, 0,    0,    0120, 0120, 0370, 0120, 0370, 0120, 0120,   /*  '#'  */
  46. 9, 0,    0,    020,  0374, 022,  0174, 0220, 0176, 020,    /*  '$'  */
  47. 9, 0,    0,    0204, 0112, 044,  020,  0110, 0244, 0102,   /*  '%'  */
  48. 8, 0,    0,    0144, 0230, 0220, 0250, 0104, 0240, 0100,   /*  '&'  */
  49. 3, 0,    0,    0,    0,    0,    0,    0200, 0100, 0100,   /*  '''  */
  50. 5, 0,    0,    040,  0100, 0200, 0200, 0200, 0100, 040,    /*  '('  */
  51. 5, 0,    0,    0200, 0100, 040,  040,  040,  0100, 0200,   /*  ')'  */
  52. 7, 0,    0,    0250, 0160, 0330, 0160, 0250, 0,    0,      /*  '*'  */
  53. 7, 0,    0,    040,  040,  0370, 040,  040,  0,    0,      /*  '+'  */
  54. 4, 0200, 0100, 0100, 0,    0,    0,    0,    0,    0,      /*  ','  */
  55. 7, 0,    0,    0,    0,    0,    0370, 0,    0,    0,      /*  '-'  */
  56. 3, 0,    0,    0200, 0,    0,    0,    0,    0,    0,      /*  '.'  */
  57. 9, 0,    0,    0200, 0100, 040,  020,  010,  04,   02,     /*  '/'  */
  58. 9, 0,    0,    070,  0104, 0202, 0202, 0202, 0104, 070,    /*  '0'  */
  59. 6, 0,    0,    0160, 0040, 0040, 0040, 0040, 0140, 0040,   /*  '1'  */
  60. 8, 0,    0,    0374, 0200, 0160, 010,  04,   0204, 0170,   /*  '2'  */
  61. 8, 0,    0,    0170, 0204, 04,   070,  04,   0204, 0170,   /*  '3'  */
  62. 8, 0,    0,    010,  010,  0374, 0210, 0110, 050,  010,    /*  '4'  */
  63. 8, 0,    0,    0160, 0210, 04,   010,  0360, 0200, 0370,   /*  '5'  */
  64. 8, 0,    0,    0170, 0204, 0204, 0370, 0100, 040,  020,    /*  '6'  */
  65. 8, 0,    0,    0100, 0100, 0100, 040,  020,  010,  0374,   /*  '7'  */
  66. 9, 0,    0,    070,  0104, 0202, 0104, 070,  0104, 070,    /*  '8'  */
  67. 8, 0,    0,    040,  020,  010,  0170, 0204, 0204, 0170,   /*  '9'  */
  68. 4, 0,    0,    0,    0300, 0,    0,    0300, 0,    0,      /*  ':'  */
  69. 5, 0,    0200, 0100, 0140, 0,    0140, 0,    0,    0,      /*  ';'  */
  70. 6, 0,    0,    020,  040,  0100, 0200, 0100, 040,  020,    /*  '<'  */
  71. 7, 0,    0,    0,    0,    0370, 0,    0370, 0,    0,      /*  '='  */
  72. 6, 0,    0,    0200, 0100, 040,  020,  040,  0100, 0200,   /*  '>'  */
  73. 8, 0,    0,    040,  0,    040,  020,  010,  0204, 0170,   /*  '?'  */
  74. 10,   0, 0,    076,  0100, 0236, 0245, 0231, 0102, 074,    /*  '@'  */
  75. 9, 0,    0,    0202, 0202, 0376, 0202, 0104, 050,  020,    /*  'A'  */
  76. 8, 0,    0,    0370, 0204, 0204, 0370, 0204, 0204, 0370,   /*  'B'  */
  77. 8, 0,    0,    0170, 0204, 0200, 0200, 0200, 0204, 0170,   /*  'C'  */
  78. 8, 0,    0,    0370, 0204, 0204, 0204, 0204, 0204, 0370,   /*  'D'  */
  79. 8, 0,    0,    0374, 0200, 0200, 0360, 0200, 0200, 0374,   /*  'E'  */
  80. 8, 0,    0,    0200, 0200, 0200, 0360, 0200, 0200, 0374,   /*  'F'  */
  81. 8, 0,    0,    0170, 0204, 0204, 0214, 0200, 0204, 0170,   /*  'G'  */
  82. 8, 0,    0,    0204, 0204, 0204, 0374, 0204, 0204, 0204,   /*  'H'  */
  83. 5, 0,    0,    0340, 0100, 0100, 0100, 0100, 0100, 0340,   /*  'I'  */
  84. 7, 0,    0,    0140, 0220, 020,  020,  020,  020,  070,    /*  'J'  */
  85. 8, 0,    0,    0204, 0210, 0220, 0340, 0220, 0210, 0204,   /*  'K'  */
  86. 8, 0,    0,    0374, 0200, 0200, 0200, 0200, 0200, 0200,   /*  'L'  */
  87. 9, 0,    0,    0202, 0202, 0202, 0222, 0252, 0306, 0202,   /*  'M'  */
  88. 9, 0,    0,    0202, 0206, 0212, 0222, 0242, 0302, 0202,   /*  'N'  */
  89. 8, 0,    0,    0170, 0204, 0204, 0204, 0204, 0204, 0170,   /*  'O'  */
  90. 8, 0,    0,    0200, 0200, 0200, 0370, 0204, 0204, 0370,   /*  'P'  */
  91. 8, 0,    0,    064,  0110, 0224, 0204, 0204, 0110, 060,    /*  'Q'  */
  92. 8, 0,    0,    0204, 0210, 0220, 0370, 0204, 0204, 0370,   /*  'R'  */
  93. 8, 0,    0,    0170, 0204, 04,   0170, 0200, 0204, 0170,   /*  'S'  */
  94. 6, 0,    0,    040,  040,  040,  040,  040,  040,  0370,   /*  'T'  */
  95. 9, 0,    0,    070,  0104, 0202, 0202, 0202, 0202, 0202,   /*  'U'  */
  96. 9, 0,    0,    020,  050,  0104, 0202, 0202, 0202, 0202,   /*  'V'  */
  97. 9, 0,    0,    0202, 0306, 0252, 0222, 0202, 0202, 0202,   /*  'W'  */
  98. 9, 0,    0,    0202, 0104, 050,  020,  050,  0104, 0202,   /*  'X'  */
  99. 9, 0,    0,    020,  020,  020,  020,  050,  0104, 0202,   /*  'Y'  */
  100. 8, 0,    0,    0374, 0200, 0100, 040,  020,  010,  0374,   /*  'Z'  */
  101. 5, 0,    0,    0340, 0200, 0200, 0200, 0200, 0200, 0340,   /*  '['  */
  102. 9, 0,    0,    02,   04,   010,  020,  040,  0100, 0200,   /*  '\'  */
  103. 5, 0,    0,    0340, 040,  040,  040,  040,  040,  0340,   /*  ']'  */
  104. 6, 0,    0,    0,    0,    0,    0,    0210, 0120, 040,    /*  '^'  */
  105. 8, 0,    0377, 0,    0,    0,    0,    0,    0,    0,      /*  '_'  */
  106. 4, 0,    0,    0,    0,    0,    0,    040,  040,  0100,   /*  '`'  */
  107. 8, 0,    0,    0164, 0210, 0170, 010,  0360, 0,    0,      /*  'a'  */
  108. 7, 0,    0,    0360, 0210, 0210, 0210, 0360, 0200, 0200,   /*  'b'  */
  109. 7, 0,    0,    0170, 0200, 0200, 0200, 0170, 0,    0,      /*  'c'  */
  110. 8, 0,    0,    0164, 0210, 0210, 0210, 0170, 010,  010,    /*  'd'  */
  111. 8, 0,    0,    0170, 0200, 0370, 0204, 0170, 0,    0,      /*  'e'  */
  112. 6, 0,    0,    0100, 0100, 0100, 0340, 0100, 0110, 060,    /*  'f'  */
  113. 7, 0360, 010,  0170, 0210, 0210, 0210, 0160, 0,    0,      /*  'g'  */
  114. 7, 0,    0,    0210, 0210, 0210, 0210, 0360, 0200, 0200,   /*  'h'  */
  115. 5, 0,    0,    0340, 0100, 0100, 0100, 0300, 0,    0100,   /*  'i'  */
  116. 7, 0140, 0220, 020,  020,  020,  020,  020,  0,    020,    /*  'j'  */
  117. 7, 0,    0,    0210, 0220, 0240, 0300, 0240, 0220, 0200,   /*  'k'  */
  118. 5, 0,    0,    0340, 0100, 0100, 0100, 0100, 0100, 0300,   /*  'l'  */
  119. 9, 0,    0,    0222, 0222, 0222, 0222, 0356, 0,    0,      /*  'm'  */
  120. 8, 0,    0,    0104, 0104, 0104, 0104, 0270, 0,    0,      /*  'n'  */
  121. 7, 0,    0,    0160, 0210, 0210, 0210, 0160, 0,    0,      /*  'o'  */
  122. 7, 0200, 0200, 0360, 0210, 0210, 0210, 0360, 0,    0,      /*  'p'  */
  123. 7, 010,  010,  0170, 0210, 0210, 0210, 0170, 0,    0,      /*  'q'  */
  124. 6, 0,    0,    0200, 0200, 0200, 0310, 0260, 0,    0,      /*  'r'  */
  125. 7, 0,    0,    0360, 010,  0160, 0200, 0170, 0,    0,      /*  's'  */
  126. 7, 0,    0,    020,  050,  040,  040,  0370, 040,  040,    /*  't'  */
  127. 8, 0,    0,    0164, 0210, 0210, 0210, 0210, 0,    0,      /*  'u'  */
  128. 8, 0,    0,    040,  0120, 0210, 0210, 0210, 0,    0,      /*  'v'  */
  129. 9, 0,    0,    0104, 0252, 0222, 0222, 0202, 0,    0,      /*  'w'  */
  130. 8, 0,    0,    0210, 0120, 040,  0120, 0210, 0,    0,      /*  'x'  */
  131. 8, 0360, 010,  0170, 0210, 0210, 0210, 0210, 0,    0,      /*  'y'  */
  132. 8, 0,    0,    0370, 0100, 040,  020,  0370, 0,    0,      /*  'z'  */
  133. 6, 0,    0,    060,  0100, 0100, 0200, 0100, 0100, 060,    /*  '{'  */
  134. 3, 0,    0,    0200, 0200, 0200, 0,    0200, 0200, 0200,   /*  '|'  */
  135. 7, 0,    0,    0300, 040,  040,  020,  040,  040,  0300,   /*  '}'  */
  136. 7, 0,    0,    0,    0,    0,    0,    020,  0250, 0100,   /*  '~'  */
  137. 7, 0,    0,    040,  0160, 0250, 040,  040,  0,    0,      /*  'd'  */
  138. };
  139.  
  140. alpha_plot(c)
  141. char c;
  142. {
  143.     int width;
  144.     int index = c - ' ';
  145.     char *ptr;
  146.     short x,y,i,j;
  147.  
  148.     if((index < 0) || (index >= sizeof(table))) return;
  149.  
  150.     ptr = table[index];
  151.     width = ((int)*ptr++ & 0377);
  152.  
  153.     /* Move so that the character is plotted with its center (approx)
  154.      * is plotted at the current point.  We have to undo this at the
  155.      * end.
  156.      */
  157.     curxdot -= 3;
  158.     curydot -= 3;
  159.     /* this is a hack--character height changes due to different
  160.      * dot densities in x and y.  we restore this at the end.
  161.      */
  162.     if(Rotate) --curydot;
  163.     
  164.     for(i = 0;i < 9; ++i)
  165.     {
  166.         if(ptr[i])
  167.         {
  168.             for(j = 0; j < 8; ++j)
  169.             {
  170.                 if(plotbit(ptr[i],j))
  171.                 {
  172.                     x = curxdot + 7 - j;
  173.                     y = curydot + i - 2;
  174.                     point(x,y);
  175.                 }
  176.             }
  177.         }
  178.     }
  179.     if(Rotate)
  180.     {
  181.         /* different dot densities, again                            */
  182.         width = (double)width * YPERINCH / XPERINCH;
  183.         curydot++;    /* end hack                                        */
  184.     }
  185.     curx += (double)width/mapxfac;
  186.     curxdot += 3;
  187.     curydot += 3;
  188.     curxdot += width;
  189. }
  190.