home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / VOGLE.ZIP / EXAMPLES / MSWIN / JTEXT.C < prev    next >
C/C++ Source or Header  |  1994-04-27  |  3KB  |  215 lines

  1. #include <stdio.h>
  2. #include "vogle.h"
  3.  
  4. /*
  5.  * demonstrate still more features of text
  6.  */
  7. main(argc, argv)
  8.     int    argc;
  9.     char    **argv;
  10. {
  11.     char    dev[20];
  12.  
  13.     vinit("mswin");
  14.  
  15.     if (argc == 2)
  16.         font(argv[1]);
  17.     else
  18.         font("futura.l");
  19.  
  20.     textsize(0.03, 0.04);
  21.  
  22.     ortho2(0.0, 1.0, 0.0, 1.0);
  23.  
  24.     color(RED);
  25.     clear();
  26.  
  27.     drawstuff();
  28.  
  29.     /* Now do it all with the text rotated .... */
  30.  
  31.     textang(45.0);
  32.     drawstuff();
  33.  
  34.     textang(160.0);
  35.     drawstuff();
  36.  
  37.     textang(270.0);
  38.     drawstuff();
  39.  
  40.     /* Now with a single character */
  41.  
  42.     textjustify(0);
  43.  
  44.     drawstuff2(0.0);
  45.  
  46.     drawstuff2(90.0);
  47.  
  48.     drawstuff2(160.0);
  49.  
  50.     drawstuff2(270.0);
  51.  
  52.     vexit();
  53. }
  54.  
  55. drawstuff()
  56. {
  57.     color(BLACK);
  58.     polyfill(1);    /* So rect clears a bit for us */
  59.     rect(0.1, 0.1, 0.9, 0.9);
  60.     color(WHITE);
  61.     move2(0.1, 0.5);
  62.     draw2(0.9, 0.5);
  63.     move2(0.5, 0.1);
  64.     draw2(0.5, 0.9);
  65.  
  66.     color(GREEN);
  67.     move2(0.5, 0.5);
  68.     leftjustify();
  69.     drawstr("This is Left Justified text");
  70.  
  71.     getkey();
  72.  
  73.     color(BLACK);
  74.     rect(0.1, 0.1, 0.9, 0.9);
  75.     color(WHITE);
  76.     move2(0.1, 0.5);
  77.     draw2(0.9, 0.5);
  78.     move2(0.5, 0.1);
  79.     draw2(0.5, 0.9);
  80.  
  81.     color(YELLOW);
  82.     move2(0.5, 0.5);
  83.     centertext(1);
  84.     drawstr("This is Centered text");
  85.     centertext(0);
  86.  
  87.     getkey();
  88.  
  89.     color(BLACK);
  90.     rect(0.1, 0.1, 0.9, 0.9);
  91.     color(WHITE);
  92.     move2(0.1, 0.5);
  93.     draw2(0.9, 0.5);
  94.     move2(0.5, 0.1);
  95.     draw2(0.5, 0.9);
  96.  
  97.     color(MAGENTA);
  98.     move2(0.5, 0.5);
  99.     rightjustify();
  100.     drawstr("This is Right Justified text");
  101.     textjustify(0);
  102.  
  103.     getkey();
  104. }
  105.  
  106. drawstuff2(ang)
  107.     float    ang;
  108. {
  109.     color(BLACK);
  110.     rect(0.1, 0.1, 0.9, 0.9);
  111.     color(WHITE);
  112.     move2(0.1, 0.5);
  113.     draw2(0.9, 0.5);
  114.     move2(0.5, 0.1);
  115.     draw2(0.5, 0.9);
  116.  
  117.     textang(ang);
  118.  
  119.     color(GREEN);
  120.     move2(0.5, 0.5);
  121.     leftjustify();
  122.     drawchar('B');
  123.  
  124.     textang(0.0);
  125.     textjustify(0);
  126.     boxtext(0.1, 0.1, 0.4, 0.02, "The 'B' should be leftjustified");
  127.     
  128.     getkey();
  129.  
  130.     color(BLACK);
  131.     rect(0.1, 0.1, 0.9, 0.9);
  132.     color(WHITE);
  133.     move2(0.1, 0.5);
  134.     draw2(0.9, 0.5);
  135.     move2(0.5, 0.1);
  136.     draw2(0.5, 0.9);
  137.  
  138.     textang(ang);
  139.     color(YELLOW);
  140.     move2(0.5, 0.5);
  141.     centertext(1);
  142.     drawchar('B');
  143.     centertext(0);
  144.  
  145.     textang(0.0);
  146.     textjustify(0);
  147.     boxtext(0.1, 0.1, 0.4, 0.02, "The 'B' should be centered");
  148.  
  149.     getkey();
  150.  
  151.     color(BLACK);
  152.     rect(0.1, 0.1, 0.9, 0.9);
  153.     color(WHITE);
  154.     move2(0.1, 0.5);
  155.     draw2(0.9, 0.5);
  156.     move2(0.5, 0.1);
  157.     draw2(0.5, 0.9);
  158.  
  159.     textang(ang);
  160.     color(MAGENTA);
  161.     move2(0.5, 0.5);
  162.     rightjustify();
  163.     drawchar('B');
  164.  
  165.     textang(0.0);
  166.     textjustify(0);
  167.     boxtext(0.1, 0.1, 0.4, 0.02, "The 'B' should be rightjustified");
  168.  
  169.     getkey();
  170.  
  171.     color(BLACK);
  172.     rect(0.1, 0.1, 0.9, 0.9);
  173.     color(WHITE);
  174.     move2(0.1, 0.5);
  175.     draw2(0.9, 0.5);
  176.     move2(0.5, 0.1);
  177.     draw2(0.5, 0.9);
  178.  
  179.     textang(ang);
  180.     color(MAGENTA);
  181.     move2(0.5, 0.5);
  182.     topjustify();
  183.     drawchar('B');
  184.  
  185.     textang(0.0);
  186.     textjustify(0);
  187.     boxtext(0.1, 0.1, 0.4, 0.02, "The 'B' should be topjustified");
  188.  
  189.     getkey();
  190.  
  191.     color(BLACK);
  192.     rect(0.1, 0.1, 0.9, 0.9);
  193.     color(WHITE);
  194.     move2(0.1, 0.5);
  195.     draw2(0.9, 0.5);
  196.     move2(0.5, 0.1);
  197.     draw2(0.5, 0.9);
  198.  
  199.     textang(ang);
  200.     color(MAGENTA);
  201.     move2(0.5, 0.5);
  202.     topjustify();
  203.     rightjustify();
  204.     drawchar('B');
  205.  
  206.     textang(0.0);
  207.     textjustify(0);
  208.     boxtext(0.1, 0.1, 0.4, 0.02, "The 'B' should be right/topjustified");
  209.  
  210.     textjustify(0);
  211.  
  212.     getkey();
  213.  
  214. }
  215.