home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / voglew.zip / CIRCTXT.C < prev    next >
C/C++ Source or Header  |  1993-05-28  |  2KB  |  144 lines

  1.  
  2. #include <stdio.h>
  3. #include "vogle.h"
  4.  
  5. #ifdef    TC
  6. #define    poly    _poly
  7. #endif 
  8.  
  9. #include <math.h>
  10.  
  11. #ifdef TC
  12. #undef    poly
  13. #define    poly    poly
  14. #endif
  15.  
  16. #define pi 3.1415926535
  17.  
  18. char *fonts[] = {
  19.     "astrology",
  20.     "cursive",
  21.     "futura.l",
  22.     "futura.m",
  23.     "gothic.eng",
  24.     "gothic.ger",
  25.     "gothic.ita",
  26.     "greek",
  27.     "japanese",
  28.     "markers",
  29.     "math.low",
  30.     "math.upp",
  31.     "meteorology",
  32.     "music",
  33.     "cyrillic",
  34.     "script",
  35.     "symbolic",
  36.     "times.g",
  37.     "times.ib",
  38.     "times.i",
  39.     "times.r",
  40.     "times.rb"
  41. };
  42.  
  43. /*
  44.  * display all the hershey fonts and demonstrate textang
  45.  */
  46. main()
  47. {
  48.     char    buf[50];
  49.     char    *str1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
  50.     char    *str2 = "abcdefghijklmnopqrstuvwxyz" ;
  51.     char    *str3 = "1234567890+-=!@#$%^&*(){}[]" ;
  52.     char    *str4 = "<>,./?~`\\|_BONK,blark" ;
  53.     int    i;
  54.  
  55.     vinit("mswin");
  56.  
  57.     color(BLACK);
  58.     clear();
  59.  
  60.     ortho2(-14.0, 14.0, -14.0, 14.0);    /* define the world space */
  61.  
  62.     for(i = 0; i < 22; i++) {
  63.  
  64.         /*
  65.          * textang is used to specify the orientation of text. As
  66.          * we want the title to come out straight we make sure it is
  67.          * zero each time we go through this loop.
  68.          */
  69.         textang(0.0);
  70.  
  71.         /*
  72.          * do the title
  73.          */
  74.         color(YELLOW);
  75.         font("futura.m");
  76.         sprintf(buf, "This is hershey font %s", fonts[i]);
  77.         boxtext(-11.0, 12.0, 20.0, 1.0, buf);
  78.  
  79.         /*
  80.          * draw a box around the title
  81.          */
  82.         rect(-11.0, 12.0, 9.0, 13.0);
  83.  
  84.         color(GREEN);
  85.  
  86.         font(fonts[i]);        /* grab a font from the table */
  87.  
  88.         textsize(1.5, 1.5);        /* show the outer ring */
  89.         ShowCircularText(11.0, str1);
  90.  
  91.         textsize(1.3, 1.3);        /* show the second ring */
  92.         ShowCircularText(8.5, str2);
  93.  
  94.         textsize(1.1, 1.1);        /* show the third ring */
  95.         ShowCircularText(7.0, str3);
  96.  
  97.         textsize(0.9, 0.9);        /* show the inside ring */
  98.         ShowCircularText(5.0, str4);
  99.  
  100.         getkey();
  101.  
  102.         color(BLACK);
  103.         clear();
  104.     }
  105.  
  106.     vexit();
  107. }
  108.  
  109. /*
  110.  * ShowCircularText
  111.  *
  112.  *    show a ring of text
  113.  */
  114. ShowCircularText(r, str)
  115.     double    r;
  116.     char    *str;
  117. {
  118.     double    i, inc, x, y;
  119.     double    a;
  120.  
  121.     inc = 360.0 / (double)strlen(str);
  122.  
  123.     for (i = 0; i < 360.0; i += inc) {
  124.         /*
  125.          * calculate the next drawing position
  126.          */
  127.         x = r * cos(i * pi / 180.0);
  128.         y = r * sin(i * pi / 180.0);
  129.         move2(x, y);
  130.         /*
  131.          * calculate angle for next character
  132.          */
  133.         a = (90 + i);
  134.         /*
  135.          * set the orientation of the next character
  136.          */
  137.         textang(a);
  138.         /*
  139.          * draw the character
  140.          */
  141.         drawchar(*str++);
  142.     }
  143. }
  144.