home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / voglew.zip / MORETXT.C < prev    next >
Text File  |  1993-05-28  |  3KB  |  179 lines

  1. #include <stdio.h>
  2. #include "vogle.h"
  3.  
  4. /*
  5.  * drawgrid
  6.  *
  7.  *    draw a grid in the middle of the screen
  8.  */
  9. drawgrid()
  10. {
  11.     float    x;
  12.     int    i;
  13.  
  14.     color(GREEN);
  15.  
  16.     rect(0.1, 0.4, 0.9, 0.6);
  17.  
  18.     x = 0.2;
  19.     for (i = 0; i < 8; i++) {
  20.         move2(x, 0.4);
  21.         draw2(x, 0.6);
  22.         x += 0.1;
  23.     }
  24.     move2(0.1, 0.5);
  25.     draw2(0.9, 0.5);
  26.  
  27.     color(YELLOW);
  28. }
  29.  
  30. /*
  31.  * demonstrate some more features of text
  32.  */
  33. main(argc, argv)
  34.     int    argc;
  35.     char    **argv;
  36. {
  37.     int    i;
  38.     float    x;
  39.     
  40.     vinit("mswin");
  41.  
  42.     if (argc == 2)
  43.         font(argv[1]);
  44.  
  45.     ortho2(0.0, 1.0, 0.0, 1.0);
  46.  
  47.     drawgrid();
  48.  
  49.     /*
  50.      * show some scaled text on the grid (In the bottom part)
  51.      */
  52.     boxtext(0.1, 0.4, 0.8, 0.1, "{This is Some text] | $");
  53.  
  54.     getkey();
  55.  
  56.     color(BLACK);
  57.     clear();
  58.  
  59.     drawgrid();
  60.  
  61.     /*
  62.      * centertext causes text to be centered around the current graphics
  63.      * position this is especially usefull if you want your text to come
  64.      * out centered on a line, or a character to be centered on a point
  65.      * in a graph. A non-zero argument turns centertext on.
  66.      *
  67.      * show a string centered on the center line
  68.      */
  69.     centertext(1);
  70.  
  71.     boxtext(0.5, 0.5, 0.8, 0.1, "{This is Some Centered text] | $");
  72.  
  73.     /*
  74.      * turn centertext off. We use an argument with the value zero.
  75.      */
  76.     centertext(0);
  77.  
  78.     getkey();
  79.  
  80.     color(BLACK);
  81.     clear();
  82.  
  83.     /*
  84.      * rotate the grid so that it is the same angle as the text after
  85.      * textang for text ang.
  86.      */
  87.     pushmatrix();
  88.         translate(0.5, 0.5, 0.0);
  89.         rotate(90.0, 'z');
  90.         translate(-0.5, -0.5, 0.0);
  91.  
  92.         drawgrid();
  93.     popmatrix();
  94.  
  95.     /*
  96.      * turn on centered text again
  97.      */
  98.     centertext(1);
  99.  
  100.     /*
  101.      * set the angle to 90.
  102.      */
  103.     textang(90.0);
  104.  
  105.     /*
  106.      * draw the string
  107.      */
  108.     boxtext(0.5, 0.5, 0.8, 0.1, "{This is Some Rotated Centered text] | $");
  109.  
  110.     /*
  111.      * turn off center text
  112.      */
  113.     centertext(0);
  114.  
  115.     /*
  116.      * set text angle back to 90
  117.      */
  118.     textang(0.0);
  119.  
  120.     getkey();
  121.  
  122.     color(BLACK);
  123.     clear();
  124.  
  125.     drawgrid();
  126.  
  127.     /*
  128.      * as all the software fonts are proportionally spaced we use
  129.      * the fixedwidth call to make each character take the same amount
  130.      * of horizontal space. As with centertext this is done by passing
  131.      * fixedwidth a non-zero argument.
  132.      */
  133.     fixedwidth(1);
  134.  
  135.     boxtext(0.1, 0.5, 0.8, 0.1, "{This is Some Fixedwidth text] | $");
  136.  
  137.     getkey();
  138.  
  139.     color(BLACK);
  140.     clear();
  141.  
  142.     drawgrid();
  143.  
  144.     /*
  145.      * now try centered and fixewidth at the same time
  146.      */
  147.     centertext(1);
  148.  
  149.     move2(0.5, 0.5);
  150.     drawstr("{This is Some Cent.Fixedwidth text] | $");
  151.  
  152.     centertext(0);
  153.     
  154.     getkey();
  155.     color(BLACK);
  156.     clear();
  157.  
  158.     drawgrid();
  159.  
  160.     /*
  161.      * scale the text so tha a character is the size of a box in
  162.      * the grid.
  163.      */
  164.     boxfit(0.8, 0.1, 8);
  165.  
  166.     /*
  167.      * draw the two strings fixedwidth (it is still turned on)
  168.      */
  169.     move2(0.1, 0.4);
  170.     drawstr("ABCDefgh");
  171.  
  172.     move2(0.1, 0.5);
  173.     drawstr("IJKLmnop");
  174.  
  175.     getkey();
  176.  
  177.     vexit();
  178. }
  179.