home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / splot122.zip / DEMO / CHARTABL.SPT < prev    next >
Text File  |  1994-07-26  |  3KB  |  133 lines

  1. /* This file displays all the available characters */
  2.  
  3. #include <splot.h>       
  4. #define ROMAN 1
  5. #define GREEK 0
  6. #define ITALIC 0
  7. int i,j;
  8. char c[10];
  9.  
  10. main()
  11.    {
  12.    set(PAGEROT,ON);
  13. #if ROMAN
  14.    text(13.67,19.14,"Roman",CENTER);
  15.    text(7.5,18,"Simplex",CENTER);
  16.    text(19,18,"Complex",CENTER);
  17.    gsave();
  18.    scale(1.2,1.2);
  19.    translate(1,-11);
  20.    set(FONTWIDTH,0.5);
  21.    set(FONTASPECT,1.5);
  22.    table(0);
  23.    translate(10,0);
  24.    set(FONT,COMPLEX);
  25.    table(0);
  26.    set(FONT,SIMPLEX);
  27. #endif
  28. #if GREEK
  29.    text(13.67,19.14,"Greek",CENTER);
  30.    text(7.5,18,"Simplex",CENTER);
  31.    text(19,18,"Complex",CENTER);
  32.    gsave();
  33.    scale(1.2,1.2);
  34.    translate(1,-11);
  35.    set(FONTWIDTH,0.5);
  36.    set(FONTASPECT,1.5);
  37.    table(1);
  38.    translate(10,0);
  39.    set(FONT,COMPLEX);
  40.    table(1);
  41.    set(FONT,SIMPLEX);
  42. #endif
  43. #if ITALIC
  44.    text(7.5,18,"Italics Simplex/Complex",CENTER);
  45.    text(19,18,"Symbols",CENTER);
  46.    gsave();
  47.    scale(1.2,1.2);
  48.    translate(1,-11);
  49.    set(FONTWIDTH,0.5);
  50.    set(FONTASPECT,1.5);
  51.    table(2);
  52.    translate(10,0);
  53.    table(3);
  54. #endif
  55.    grestore();
  56.    }
  57.  
  58. table(int special)
  59.    {
  60.    /* label rows and columns */
  61.    c[1] = '\0';
  62.    for (i = 0; i < 10;i++)
  63.       {
  64.       c[0] = '0' + i;
  65.       tputs(2 + i * 0.7,24.5,c,0);
  66.       }
  67.    c[0] = ' ';
  68.    c[2] = '0';
  69.    c[3] = '\0';
  70.    for (j = 3;j < 10;j++)
  71.       {
  72.       c[1] = '0' + j;
  73.       tputs(0,26 - j,c,0);
  74.       }
  75.    c[0] = '1';
  76.    c[2] = '0';
  77.    c[3] = '\0';
  78.    for (j = 10;j < 13;j++)
  79.       {
  80.       c[1] = '0' + j - 10;
  81.       tputs(0,26 - j,c,0);
  82.       }
  83.    /* prepend each char with '\' so that even special chars get printed */
  84.    c[0] = '\\';
  85.    c[2] = '\0';
  86.    box(1.29,23.77,9.07,13.36);
  87.    stroke();
  88.    /* fill in table */
  89.    for (j = 3;j < 13;j++)
  90.       {
  91.       for (i = 0; i < 10;i++)
  92.          {
  93.          c[1] = j * 10 + i;
  94.          if (c[1] == 'b')
  95.             tputs(2 + i * 0.7,26 - j,"b",special);
  96.          else
  97.             tputs(2 + i * 0.7,26 -j,c,special);
  98.          }
  99.       }
  100.    }
  101.  
  102. tputs(double x,double y,char *c,int special) 
  103.    {
  104.    char tmp[10];
  105.    switch(special)
  106.       {
  107.       case 0:
  108.          text(x,y,c);
  109.          break;
  110.       case 1:
  111.          /* greek */
  112.          strcpy(tmp,"!");
  113.          strcat(tmp,c);
  114.          strcat(tmp,"!");
  115.          text(x,y,tmp);
  116.          break;
  117.       case 2:
  118.          /* italics */
  119.          strcpy(tmp,"#");
  120.          strcat(tmp,c);
  121.          strcat(tmp,"#");
  122.          text(x,y,tmp);
  123.          break;
  124.       case 3:
  125.          /* symbols */
  126.          strcpy(tmp,"$");
  127.          strcat(tmp,c);
  128.          strcat(tmp,"$");
  129.          text(x,y,tmp);
  130.          break;
  131.       }
  132.    }
  133.