home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 325_02 / demo1.c < prev    next >
C/C++ Source or Header  |  1990-03-27  |  21KB  |  910 lines

  1. #include    <stdio.h>
  2. #include    <string.h>
  3. #include    <conio.h>
  4. #include    <math.h>
  5. #include    <stdlib.h>
  6. #include    <grph.h>
  7. #include    <ops2d.h>
  8. #include    <font.h>
  9. #include    <pattern.h>
  10.  
  11. extern        Byte    ModeNo;
  12. extern        int     strtln;
  13. struct    VP  vp1;            /* Viewport */
  14.  
  15. extern void Delay(long);
  16.  
  17. static void near figure(int,int,int,int);
  18.  
  19. extern    void    pttrn1(void);
  20.  
  21. void    curves(void)
  22. {
  23.  
  24.     SetClipOff();                /* clipping off, to clear screen */
  25.     SetFillPattern(1,0,0,Fp[19]);
  26.     ClearScreen();
  27.     PxlClr=7;
  28.     Rectangl(0,0,XRes,YRes);            /* Rectangle for whole screen */
  29.  
  30.     BFntStClr(14);                /* Text display color */
  31.     strtln = 1;                 /* Start line of text display */
  32.     BFntStLctn((XRes>>1)-BFntHght*16,strtln);      /* Start position of Text  */
  33.     strtln += BFntHght;               /* for next line of text */
  34.     BFntDsply("Drawing Curves by Setting Pixels");
  35.     BFntStLctn((XRes>>1)-16*12,strtln);       /* set next postion */
  36.     BFntDsply("Four Different ViewPorts");
  37.  
  38.     vp1.x1 = 2;             /* viewport upper-left    x */
  39.     vp1.y1 = strtln+BFntHght+2;     /*        upper-left    y */
  40.     vp1.x2 = ((XRes>>1)+vp1.x1+2);    /*        lower-right x */
  41.     vp1.y2 = ((YRes>>1)+vp1.y1+2);    /*        lower-right y */
  42.     SetClipOff();            /* to draw rectangle */
  43.  
  44.     Rectangl(vp1.x1,vp1.y1,vp1.x2,vp1.y2);
  45.     FillRectangle(vp1.x1+1,vp1.y1+1,vp1.x2-1,vp1.y2-1);
  46.     SetViewPort(vp1);
  47.     SetClipOn();            /* Drawings will be clipped */
  48.     MapWorld((float)(vp1.x1),(float)(vp1.y1),\
  49.          (float)(vp1.x2),(float)(vp1.y2));     /* World C0-ordinates = */
  50.                          /* viewport boundaries  */
  51.  
  52.     PxlClr = 15;    /* draw the curve in this color */
  53.     figure(0,vp1.x1+((vp1.x2-vp1.x1)>>1),vp1.y1+((vp1.y2-vp1.y1)>>1),80);
  54.  
  55.     vp1.x1 = vp1.x2+2;            /* change only upper-left x and */
  56.                     /* lower right x for next viewport */
  57.     vp1.x2 = XRes-2;
  58.  
  59.     SetClipOff();
  60.     PxlClr = 7;
  61.     Rectangl(vp1.x1,vp1.y1,vp1.x2,vp1.y2);
  62.     FllClr = 2;
  63.     FillRectangle(vp1.x1+1,vp1.y1+1,vp1.x2-1,vp1.y2-1);
  64.     SetViewPort(vp1);
  65.     SetClipOn();
  66.     MapWorld((float)(vp1.x1),(float)(vp1.y1),\
  67.          (float)(vp1.x2),(float)(vp1.y2));
  68.  
  69.     PxlClr = 12;
  70.     figure(1,vp1.x1+((vp1.x2-vp1.x1)>>1),vp1.y1+((vp1.y2-vp1.y1)>>1),100);
  71.  
  72.     vp1.x1 = 2;
  73.     vp1.y1 = (YRes>>1)+strtln+BFntHght+2;
  74.     vp1.x2 = ((XRes>>1)+vp1.x1+2);
  75.     vp1.y2 = (YRes-2);
  76.     SetClipOff();
  77.     PxlClr = 7;
  78.     Rectangl(vp1.x1,vp1.y1,vp1.x2,vp1.y2);
  79.     FllClr = 3;
  80.     FillRectangle(vp1.x1+1,vp1.y1+1,vp1.x2-1,vp1.y2-1);
  81.     SetViewPort(vp1);
  82.     SetClipOn();
  83.     MapWorld((float)(vp1.x1),(float)(vp1.y1),\
  84.          (float)(vp1.x2),(float)(vp1.y2));
  85.  
  86.     PxlClr = 13;
  87.     figure(2,vp1.x1+((vp1.x2-vp1.x1)>>1),vp1.y1+((vp1.y2-vp1.y1)>>1),80);
  88.  
  89.     vp1.x1 = vp1.x2+2;
  90.  
  91.     vp1.x2 = (XRes-2);
  92.  
  93.     SetClipOff();
  94.     PxlClr = 7;
  95.     Rectangl(vp1.x1,vp1.y1,vp1.x2,vp1.y2);
  96.     FllClr = 4;
  97.     FillRectangle(vp1.x1+1,vp1.y1+1,vp1.x2-1,vp1.y2-1);
  98.     SetViewPort(vp1);
  99.     SetClipOn();
  100.     MapWorld((float)(vp1.x1),(float)(vp1.y1),\
  101.          (float)(vp1.x2),(float)(vp1.y2));
  102.  
  103.     PxlClr = 11;
  104.     figure(3,vp1.x1+((vp1.x2-vp1.x1)>>1),vp1.y1+((vp1.y2-vp1.y1)>>1),100);
  105.  
  106.     getch();
  107.  
  108. }
  109.  
  110. void  near  figure(int tp,int xc,int yc,int a)       /* 4 type of curves */
  111. {
  112.  
  113.     float   t,dt,r;
  114.     float   x,y;
  115.  
  116.     t = 0.0f;
  117.     dt = 1.0f / (float)a;
  118.  
  119.     /* calculate points on the curve */
  120.  
  121.     while (t < 6.28f)
  122.     {
  123.         switch (tp)
  124.         {
  125.         case 0 : r = (float)a * (1.0f + cos(t));break;
  126.         case 1 : r = (float)a * cos(3.0f*t);break;
  127.         case 2 : r = (float)a * cos(4.0f*t);break;
  128.         case 3 : r = (float)a * cos(t * 2.0f);break;
  129.         }
  130.  
  131.         x = (float)xc + r*cos(t);
  132.         y = (float)yc + r*sin(t);
  133.  
  134.         SetPixel(WtoDX(x),WtoDY(y));    /* Pixel setting routine  */
  135.  
  136.         t = t + dt;
  137.     }
  138. }
  139.  
  140. void    ellps(void)            /* ellipse using bresenham algorithm */
  141. {
  142.  
  143.     int     xc,yc;
  144.     int     a,b,c;
  145.     int     i;
  146.  
  147.     SetDraw(0);
  148.     SetClipOff();
  149.     SetFillPattern(5,0,0,Fp[19]);
  150.     ClearScreen();
  151.  
  152.     PxlClr=15;
  153.     Rectangl(0,0,XRes,YRes);
  154.  
  155.     strtln=1;
  156.     BFntStClr(9);
  157.     BFntStLctn((XRes>>1)-8*BFntWdth,strtln);
  158.     BFntDsply("Drawing Ellipses");
  159.  
  160.     strtln += BFntHght;
  161.     LineD(1,strtln,(XRes-1),strtln);
  162.  
  163.     vp1.x1=1;
  164.     vp1.y1=strtln+1;
  165.     vp1.x2=XRes-1;
  166.     vp1.y2=YRes-1;
  167.  
  168.     FillRectangle(vp1.x1,vp1.y1,vp1.x2,vp1.y2);
  169.  
  170.     SetViewPort(vp1);
  171.     SetClipOn();
  172.  
  173.     xc = (XRes>>1)+1;            /* initial center of ellipse */
  174.     yc = (YRes>>1)+1;
  175.     a = (XRes>>1);
  176.     b = (YRes>>1);            /* initial major and minor axes*/
  177.     c = XRes>>1;            /* loop control to change size */
  178.  
  179.     SetDraw(3);
  180.  
  181.     PxlClr= 14;
  182.     do
  183.     {
  184.         for (i=c;i>0;i-=3)        /* shift, re-size, and draw */
  185.         {
  186.  
  187.             EllipseD(xc-i,yc-i,a-i,b-i);
  188.  
  189.             EllipseD(xc-i,yc-i,a-i,b-i);
  190.         }
  191.  
  192.         for (i=0;i<c;i+=3)
  193.         {
  194.  
  195.             EllipseD(xc-i,yc+i,a-i,b-i);
  196.  
  197.             EllipseD(xc-i,yc+i,a-i,b-i);
  198.         }
  199.  
  200.         for (i=c;i>0;i-=3)
  201.         {
  202.  
  203.             EllipseD(xc+i,yc-i,a-i,b-i);
  204.  
  205.             EllipseD(xc+i,yc-i,a-i,b-i);
  206.         }
  207.  
  208.         for (i=0;i<c;i+=3)
  209.         {
  210.  
  211.             EllipseD(xc+i,yc+i,a-i,b-i);
  212.  
  213.             EllipseD(xc+i,yc+i,a-i,b-i);
  214.         }
  215.     }
  216.     while (!kbhit());
  217.     getch();
  218.  
  219. }
  220. void Delay(long n)
  221. {
  222.     long    i;
  223.  
  224.     for (i=0;i<=n;i++) ;
  225. }
  226.  
  227. void arcs(void)                 /* draw arc of various params */
  228. {
  229.  
  230.     float   xc,yc,a,b;
  231.     float   t1,t2;
  232.     int     i,j;
  233.     int     ch;
  234.     float   arcx[40],arcy[40];
  235.     Word    n;
  236.  
  237.     SetDraw(0);
  238.     SetClipOff();
  239.     SetFillPattern(8,0,0,Fp[19]);
  240.     ClearScreen();
  241.  
  242.     PxlClr=15;
  243.     Rectangl(0,0,XRes,YRes);
  244.  
  245.     strtln=1;
  246.     BFntStClr(10);
  247.     BFntStLctn((XRes>>1)-6*BFntWdth,strtln);
  248.     BFntDsply("Drawing Arcs");
  249.  
  250.     strtln +=BFntHght;
  251.     BFntStLctn((XRes>>1)-18*BFntWdth,strtln);
  252.     BFntDsply("Press 'y' to end, any other key to continue");
  253.  
  254.     strtln += BFntHght;
  255.     LineD(1,strtln,(XRes-1),strtln);
  256.  
  257.     vp1.x1=1;
  258.     vp1.y1=strtln+1;
  259.     vp1.x2=XRes-1;
  260.     vp1.y2=YRes-1;
  261.  
  262.     FillRectangle(vp1.x1,vp1.y1,vp1.x2,vp1.y2);
  263.  
  264.     xc = (float)(XRes>>1);
  265.     yc = (float)(YRes>>1);
  266.  
  267.     SetViewPort(vp1);
  268.     MapWorld(-xc,-yc,xc,yc);
  269.  
  270.     SetClipOn();
  271.     SetDraw(3);
  272.  
  273.     do
  274.     {                /* axes, start and end angles */
  275.         a  = (float)abs(rand() % (XRes>>1));
  276.         b  = (float)abs(rand() % (YRes>>1));
  277.         t1 = (float)fabs((double)(rand() % 360));
  278.         t2 = (float)fabs((double)(rand() % 360));
  279.  
  280.         i = rand();
  281.         j = rand() % 29;
  282.  
  283.         PxlClr = (Byte)(rand() % 256);
  284.  
  285.         n = Arc(0.0f,0.0f,a,b,t1,t2,arcx,arcy,40);       /* get the arc */
  286.  
  287.         PolyLine(n,arcx,arcy);
  288.  
  289.         if (i % 2)
  290.         {
  291.             Line(arcx[0],arcy[0],arcx[n-1],arcy[n-1]);
  292.         }
  293.         else if (i % 3)
  294.         {
  295.             Line (0.0f,0.0f,arcx[0],arcy[0]);
  296.             Line (0.0f,0.0f,arcx[n-1],arcy[n-1]);
  297.  
  298.         }
  299.         else  if (i%4)
  300.         {
  301.             SetFillPattern(PxlClr+1,0,0,Fp[j]);
  302.             Line(arcx[0],arcy[0],arcx[n-1],arcy[n-1]);
  303.             FillPoly(n,arcx,arcy);
  304.         }
  305.         else
  306.         {
  307.         }
  308.  
  309.         ch=getch();
  310.                     /* draw it again in back-ground color */
  311.  
  312.         if (i % 2)
  313.         {
  314.             Line(arcx[0],arcy[0],arcx[n-1],arcy[n-1]);
  315.         }
  316.         else if (i % 3)
  317.         {
  318.             Line (0.0f,0.0f,arcx[0],arcy[0]);
  319.             Line (0.0f,0.0f,arcx[n-1],arcy[n-1]);
  320.  
  321.         }
  322.         else if (i%4)
  323.         {
  324.             SetFillPattern(PxlClr+1,0,0,Fp[j]);
  325.             Line(arcx[0],arcy[0],arcx[n-1],arcy[n-1]);
  326.             FillPoly(n,arcx,arcy);
  327.         }
  328.         else
  329.         {
  330.         }
  331.         PolyLine(n,arcx,arcy);
  332.  
  333.     }
  334.     while ((ch != 'y') && (ch != 'Y'));
  335.  
  336. }
  337.  
  338. void pttrn1()                   /* fill ellipses with patterns */
  339.  
  340. {
  341.     float   a,b;
  342.     Byte    BClr,zc;
  343.     int     Pttrn;
  344.  
  345.     SetDraw(0);
  346.     SetFillPattern(8,0,0,Fp[19]);
  347.     SetClipOff();
  348.     ClearScreen();
  349.  
  350.     PxlClr=4;
  351.     Rectangl(0,0,XRes,YRes);
  352.  
  353.     strtln=1;
  354.     BFntStClr(11);
  355.     BFntStLctn(1,strtln);
  356.     BFntDsply("Area Fills with Holes");
  357.  
  358.     strtln += (int)BFntHght;
  359.     LineD(1,strtln,(XRes-1),strtln);
  360.  
  361.     vp1.x1=1;
  362.     vp1.y1=strtln+1;
  363.     vp1.x2=XRes-1;
  364.     vp1.y2=YRes-1;
  365.  
  366.     FillRectangle(vp1.x1,vp1.y1,vp1.x2,vp1.y2);
  367.  
  368.     SetViewPort(vp1);
  369.     SetClipOn();
  370.     SetDraw(3);
  371.  
  372.     MapWorld(-500.0f,-500.0f,500.0f,500.0f);
  373.  
  374.     do
  375.     {                /* big ellipse axes */
  376.  
  377.         a  = (float)(abs(rand()) % XRes ) + 150;
  378.         b  = (float)(abs(rand()) % YRes) + 250;
  379.  
  380.         Pttrn = (rand() %  29);    /* random pattern and colors */
  381.  
  382.         if (_ZMode== 1)
  383.         PxlClr = (Byte)(rand() % 256);        /* 256 color mode */
  384.         else
  385.         PxlClr = (Byte)(rand() % 16);        /* 16 color mode */
  386.         if ((!PxlClr) || (PxlClr == FllClr))
  387.         PxlClr = FllClr-1;
  388.  
  389.         zc = PxlClr + 1;
  390.         BClr = PxlClr^8;            /* border color = drawning color*/
  391.                         /* XOR background color */
  392.         Ellipse(0.00f,0.00f,a,b);        /* big ellipse */
  393.                         /* inside rectangle */
  394.         Rectangl(WtoDX(-100.0f),WtoDY(-100.0f),WtoDX(100.0f),WtoDY(100.0f));
  395.  
  396.         Ellipse(-120.00f,120.00f,20.0f,20.0f);
  397.         Ellipse(120.00f,-120.00f,20.0f,20.0f);    /* small ellipses */
  398.         Ellipse(-120.00f,-120.00f,20.0f,20.0f);
  399.         Ellipse(120.00f,120.00f,20.0f,20.0f);
  400.  
  401.         SetFillPattern(zc,0,0,Fp[Pttrn]);
  402.  
  403.         FillArea(WtoDX(0.00f),WtoDY(150.00f),BClr);   /* fill */
  404.  
  405.         SetFillPattern(zc,0,0,Fp[Pttrn]);
  406.                                /* erase the fill */
  407.         FillArea(WtoDX(0.00f),WtoDY(150.00f),BClr);    /* by redrawing   */
  408.                                /* every thing in */
  409.         Ellipse(120.00f,120.00f,20.0f,20.0f);       /* same color in  */
  410.         Ellipse(-120.00f,-120.00f,20.0f,20.0f);       /* XOR mode */
  411.         Ellipse(120.00f,-120.00f,20.0f,20.0f);
  412.         Ellipse(-120.00f,120.00f,20.0f,20.0f);
  413.         Rectangl(WtoDX(-100.0f),WtoDY(-100.0f),WtoDX(100.0f),WtoDY(100.0f));
  414.  
  415.         Ellipse(0.00f,0.00f,a,b);
  416.  
  417.     }
  418.     while(!kbhit());
  419.     getch();
  420. }
  421.  
  422. void dpolyfill(void)         /* polygon fill in device co-ordinates */
  423. {
  424.  
  425.     int     Pttrn;
  426.     Byte    PttClr;
  427.     static int PSx[80];
  428.     static int PSy[80];
  429.     int     i;
  430.     Word    n;
  431.  
  432.     SetDraw(0);
  433.     SetClipOff();
  434.     SetFillPattern(3,0,0,Fp[19]);
  435.     ClearScreen();
  436.  
  437.     PxlClr=2;
  438.     Rectangl(0,0,XRes,YRes);
  439.  
  440.     strtln=1;
  441.     BFntStClr(12);
  442.     BFntStLctn((XRes>>1)-18*BFntWdth,strtln);
  443.     BFntDsply("Polygon Filling in Device Co-ordinates");
  444.  
  445.     strtln += BFntHght;
  446.     LineD(1,strtln,(XRes-1),strtln);
  447.  
  448.     vp1.x1=1;
  449.     vp1.y1=strtln+1;
  450.     vp1.x2=XRes-1;
  451.     vp1.y2=YRes-1;
  452.  
  453.     FillRectangle(vp1.x1,vp1.y1,vp1.x2,vp1.y2);
  454.  
  455.     SetViewPort(vp1);
  456.     SetClipOn();
  457.     SetDraw(3);
  458.  
  459.     do
  460.     {
  461.         i  = rand() % 39;
  462.         if (i < 4)
  463.         i += 4;
  464.  
  465.         for (n=0;n<i;n++)
  466.         {
  467.             PSx[n] = (rand() % (XRes));
  468.             PSy[n] = (rand() % (YRes));
  469.  
  470.         }
  471.         PSx[i]=PSx[0];
  472.         PSy[i]=PSy[0];
  473.  
  474.         Pttrn = rand() % 29;
  475.         if (_ZMode==1)            /* 256 color mode */
  476.         {
  477.             PxlClr =(Byte)(rand() % 256);
  478.             PttClr = PxlClr + 10;
  479.         }
  480.         else
  481.         {                /* 16 color mode */
  482.             PxlClr = (Byte)(rand() % 16);
  483.             PttClr = PxlClr + 2;
  484.         }
  485.  
  486.         SetFillPattern(PttClr,0,0,Fp[Pttrn]);
  487.         FillPolyD(i,PSx,PSy);
  488.         PolyLineD((i+1),PSx,PSy);
  489.  
  490.         SetFillPattern(PttClr,0,0,Fp[Pttrn]);
  491.         FillPolyD(i,PSx,PSy);
  492.         PolyLineD((i+1),PSx,PSy);
  493.  
  494.     }
  495.     while (!(kbhit()));
  496.     getch();
  497. }
  498.  
  499. void pttrn2(void)            /* pattern reference point */
  500.  
  501. {                    /* polygon edge points */
  502.     static float x2[] = {10.0f,60.0f,100.0f,120.0f,140.0f,200.0f,250.0f,\
  503.              300.0f,230.0f,180.0f,130.0f,100.0f,80.0f,10.0f};
  504.     static float y2[] = {100.0f,9.0f,70.0f,70.0f,50.0f,80.0f,40.0f,120.0f,\
  505.              200.0f,160.0f,190.0f,140.0f,170.0f,100.0f};
  506.  
  507.     Byte    i;
  508.     Byte    j,k;
  509.  
  510.     SetDraw(0);
  511.     SetClipOff();
  512.     SetFillPattern(8,0,0,Fp[19]);
  513.     ClearScreen();
  514.  
  515.     PxlClr=13;
  516.     Rectangl(0,0,XRes,YRes);
  517.  
  518.     strtln=1;
  519.     BFntStClr(14);
  520.     BFntStLctn((XRes>>1)-14*BFntWdth,strtln);
  521.     BFntDsply("Fill Patterns Can be aligned");
  522.  
  523.     strtln += BFntHght;
  524.     BFntStLctn((XRes>>1)-11*BFntWdth,strtln);
  525.     BFntDsply("with Reference to a point");
  526.  
  527.     BFntStLctn((XRes>>1)-11*BFntWdth,(YRes-1-BFntHght));
  528.     BFntDsply("Press a key to continue");
  529.     LineD(1,(YRes-2-BFntHght),(XRes-1),(YRes-2-BFntHght));
  530.  
  531.     strtln += BFntHght;
  532.     LineD(1,strtln,(XRes-1),strtln);
  533.  
  534.     vp1.x1=1;
  535.     vp1.y1=strtln+1;
  536.     vp1.x2=XRes-1;
  537.     vp1.y2=YRes-3-BFntHght;
  538.  
  539.     FillRectangle(vp1.x1,vp1.y1,vp1.x2,vp1.y2);
  540.  
  541.     SetViewPort(vp1);
  542.     SetClipOn();
  543.     if (ModeNo==2)
  544.     MapWorld((float)vp1.x1,(float)vp1.y1,(float)vp1.x2,(float)vp1.y2);
  545.     else
  546.     MapWorld(0.00f,0.00f,320.0f,200.0f);
  547.  
  548.     PxlClr=12;                /* draw a whole */
  549.     PolyLine(14,x2,y2);
  550.     Ellipse(190.0f,120.0f,10.0f,10.0f);
  551.  
  552.     PxlClr = 15;            /* arrow line color */
  553.  
  554.     for (i=0;i<16;i++)
  555.     {
  556.         SetDraw(0);         /* replace */
  557.         if (i<8)
  558.         {
  559.             j = i;
  560.             k = 0;
  561.         }
  562.         else
  563.         {
  564.             j=0;
  565.             k=i-8;
  566.         }
  567.  
  568.         SetFillPattern(9,j,k,Fp[23]);
  569.  
  570.         if (!(i))
  571.         FillArea(WtoDX(100.0f),WtoDY(100.0f),12);
  572.         else
  573.         FillAgain();
  574.  
  575.         Line(100.0f,100.0f,100.0f,110.0f);
  576.         Line(100.0f,100.0f,110.0f,100.0f);
  577.         Line(100.0f,100.0f,150.0f,150.0f);
  578.  
  579.         getch();
  580.  
  581.         SetDraw(3);
  582.         SetFillPattern(9,j,k,Fp[23]);
  583.  
  584.         FillAgain();
  585.     }
  586.     getch();
  587.     SetFillPattern(8,0,0,Fp[19]);
  588. }                 /* text strings */
  589.  
  590.     static  char    s1[] = {"Bit-Mapped Fonts"};
  591.     static  char    s2[] = {"Font Type 8x16 (This is Normal Size)"};
  592.     static  char    s3[] = {"Size 5x5"};
  593.     static  char    s4[] = {"Size 2x4"};
  594.     static  char    s5[] = {"Size 4x2"};
  595.  
  596.     static  char    s6[] = {"Font Type 8x8 (This is Normal Size)"};
  597.     static  char    s7[] = {"Size 3x3"};
  598.     static  char    s8[] = {"Zero Orientation, Right Direction"};
  599.     static  char    s9[] = {"Default Orientation, Left Direction"};
  600.     static  char    s10[] = {"90 Degrees, Up"};
  601.     static  char    s11[] = {"90 Degrees, Down"};
  602.     static  char    s12[] = {"180 Degrees, Right"};
  603.     static  char    s13[] = {"180 Degrees, Left"};
  604.     static  char    s14[] = {"270 Degrees, Up"};
  605.     static  char    s15[] = {"270 Degrees, Down"};
  606.     static  char    s16[] = {"360 Degrees, Right"};
  607.     static  char    s17[] = {"360 Degrees, Left"};
  608.  
  609.     static  char    s18[] = {"Stroked-Fonts"};
  610.     static  char    s19[] = {"Font type 8x8 (This is Normal Size)"};
  611.     static  char    s20[] = {"Stroked Fonts can be"};
  612.     static  char    s21[] = {"Any Size, Can be in Any"};
  613.     static  char    s22[] = {"of Four Directions, and at"};
  614.     static  char    s23[] = {"Any Angle"};
  615.  
  616. static void near dsply1(void);
  617. static void near dsply2(void);
  618. static void near dsply3(void);
  619. static    void    near    StVwPrt(void);
  620.  
  621. void fnts(void)
  622. {
  623.  
  624.     StVwPrt();
  625.     dsply1();                /* bit-mapped fonts 8*16 */
  626.  
  627.     StVwPrt();                /*            8x8  */
  628.     dsply2();
  629.  
  630.     StVwPrt();                /* vector fonts         */
  631.     dsply3();
  632.  
  633. }
  634.  
  635. static void near StVwPrt(void)
  636. {
  637.  
  638.     SetDraw(0);
  639.     SetClipOff();
  640.     SetFillPattern(8,0,0,Fp[19]);
  641.     ClearScreen();
  642.  
  643.     vp1.x1 = 1;
  644.     vp1.y1 = 1;
  645.     vp1.x2 = XRes - 1;
  646.     vp1.y2 = YRes - 1;
  647.     SetClipOff();
  648.     PxlClr = 7;
  649.     Rectangl(0,0,XRes,YRes);
  650.  
  651.     FillRectangle(vp1.x1,vp1.y1,vp1.x2,vp1.y2);
  652.     SetViewPort(vp1);
  653.     MapWorld((float)(vp1.x1),(float)(vp1.y1),(float)(vp1.x2),(float)(vp1.y2));
  654.     SetClipOn();
  655. }
  656.  
  657. static void near dsply1()
  658. {
  659.     int     i,j;
  660.  
  661.     BFntInit("v8x16.fnt",16);        /* initialize and load font */
  662.  
  663.     i = 2;
  664.     BFntFClr = 9;
  665.     BFntStSz(2,2);
  666.     j = (XRes>>1) - (((strlen(s1)) >> 1) * 16);
  667.     BFntStLctn(j,i);
  668.     BFntDsply(s1);
  669.  
  670.     i += 42;
  671.  
  672.     Line(Wrldxy[0],Wrldxy[3]-(float)i,Wrldxy[2],Wrldxy[3]-(float)i);
  673.  
  674.     i += 4;
  675.     BFntFClr ++;
  676.     BFntStSz(1,1);
  677.     j = (XRes>>1) - (((strlen(s2)) >> 1) * 8);
  678.     BFntStLctn(j,i);
  679.     BFntDsply(s2);
  680.  
  681.     i += 24;
  682.     BFntFClr ++;
  683.     BFntStSz(5,5);
  684.     j = (XRes>>1) - (((strlen(s3)) >> 1) * 40);
  685.     BFntStLctn(j,i);
  686.     BFntDsply(s3);
  687.  
  688.     i += 88;
  689.     BFntFClr ++;
  690.     BFntStSz(2,4);
  691.     j = (XRes>>1) - (((strlen(s4)) >> 1) * 16);
  692.     BFntStLctn(j,i);
  693.     BFntDsply(s4);
  694.  
  695.     i += 72;
  696.     BFntFClr ++;
  697.     BFntStSz(4,2);
  698.     j = (XRes>>1) - (((strlen(s5)) >> 1) * 32);
  699.     BFntStLctn(j,i);
  700.     BFntDsply(s5);
  701.  
  702.     getch();
  703. }
  704.  
  705. static void near dsply2()
  706. {
  707.     int     i,j,k;
  708.  
  709.     BFntInit("v8x8.fnt",8);        /* init and load 8x8 font */
  710.                     /* which can be rotated */
  711.     i = 2;
  712.     BFntFClr = 9;
  713.     BFntStSz(2,2);
  714.     j = (XRes>>1) - (((strlen(s1)) >> 1) * 16);
  715.     BFntStLctn(j,i);
  716.     BFntDsply(s1);
  717.  
  718.     i += 34;
  719.  
  720.     Line(Wrldxy[0],Wrldxy[3]-(float)i,Wrldxy[2],Wrldxy[3]-(float)i);
  721.  
  722.     i += 4;
  723.     BFntFClr ++;
  724.     BFntStSz(1,1);
  725.     j = (XRes>>1) - (((strlen(s6)) >> 1) * 8);
  726.     BFntStLctn(j,i);
  727.     BFntDsply(s6);
  728.  
  729.     if (XRes == 319)
  730.     k = 1;
  731.     else
  732.     k = 2;
  733.  
  734.     i += 16;
  735.     BFntFClr ++;
  736.     BFntStSz(3,3);
  737.     j = (XRes>>1) - (((strlen(s7)) >> 1) * 24);
  738.     BFntStLctn(j,i);
  739.     BFntDsply(s7);
  740.  
  741.     i += 32;
  742.     BFntFClr ++;
  743.     BFntStSz(k,k);
  744.     j = (XRes>>1) - (((strlen(s8)) >> 1) * (k<<3));
  745.     BFntStLctn(j,i);
  746.     BFntDsply(s8);
  747.  
  748.     i += 16;
  749.     BFntFClr ++;
  750.     BFntStSz(k,k);
  751.     j = (XRes>>1) + (((strlen(s9)) >> 1) * (k<<3));
  752.     BFntStLctn(j,i);
  753.     SFntStDrctn(left);
  754.     BFntDsply(s9);
  755.  
  756.     i = 6;
  757.     BFntFClr ++;
  758.     BFntStSz(k,k);
  759.     j = (YRes>>1) + (((strlen(s10)) >> 1) * (k<<3));
  760.     BFntStLctn(i,j);
  761.     SFntStDrctn(up);
  762.     BFntStOrntn(90);            /* rotate by 90 degrees */
  763.     BFntDsply(s10);
  764.  
  765.     i = 22;
  766.     BFntFClr ++;            /* change direction from up to down */
  767.     BFntStSz(k,k);
  768.     j = (YRes>>1) - (((strlen(s11)) >> 1) * (k<<3));
  769.     BFntStLctn(i,j);
  770.     SFntStDrctn(down);
  771.  
  772.     BFntDsply(s11);
  773.  
  774.     if (_ZMode == 1)
  775.     BFntFClr = 32;
  776.  
  777.     i = YRes - 42;
  778.     BFntFClr ++;
  779.     BFntStSz(k,k);
  780.     j = (XRes>>1) - (((strlen(s12)) >> 1) * (k<<3));
  781.     BFntStLctn(j,i);
  782.     SFntStDrctn(right);
  783.     BFntStOrntn(90);            /* rotate further by 90 degrees */
  784.     BFntDsply(s12);            /* so effectively 180 degrees */
  785.  
  786.     i -= 22;
  787.     BFntFClr ++;
  788.     BFntStSz(k,k);
  789.     j = (XRes>>1) + (((strlen(s13)) >> 1) * (k<<3));
  790.     BFntStLctn(j,i);
  791.     SFntStDrctn(left);
  792.     /*BFntStOrntn(90);*/
  793.     BFntDsply(s13);
  794.  
  795.     i = XRes - 22;
  796.     BFntFClr ++;
  797.     BFntStSz(k,k);
  798.     j = (YRes>>1) + (((strlen(s14)) >> 1) * (k<<3));
  799.     BFntStLctn(i,j);
  800.     SFntStDrctn(up);
  801.     BFntStOrntn(90);            /* rotate by more 90 degrees to make */
  802.     BFntDsply(s14);            /* 270 degrees */
  803.  
  804.     i -= 22;
  805.     BFntFClr ++;
  806.     BFntStSz(k,k);
  807.     j = (YRes>>1) - (((strlen(s15)) >> 1) * (k<<3));
  808.     BFntStLctn(i,j);
  809.     SFntStDrctn(down);
  810.     /*BFntStOrntn(90);*/
  811.     BFntDsply(s15);
  812.  
  813.  
  814.     i = YRes>>1;
  815.     BFntFClr ++;
  816.     BFntStSz(k,k);
  817.     j = (XRes>>1) - (((strlen(s16)) >> 1) * (k<<3));
  818.     BFntStLctn(j,i);
  819.     SFntStDrctn(right);
  820.     BFntStOrntn(90);            /* now total of 360 degrees */
  821.     BFntDsply(s16);
  822.  
  823.     i += 22;
  824.     BFntFClr ++;
  825.     BFntStSz(k,k);
  826.     j = (XRes>>1) + (((strlen(s17)) >> 1) * (k<<3));
  827.     BFntStLctn(j,i);
  828.     SFntStDrctn(left);
  829.     /*BFntStOrntn(90);*/
  830.     BFntDsply(s17);
  831.  
  832.     getch();
  833.  
  834. }
  835.  
  836. static void near dsply3()
  837. {
  838.     int     i,j,k;
  839.     Byte    Clr;
  840.  
  841.     SFntInit("sdflt.fnt");        /* initialise and load stroked-font */
  842.     Clr = 57;
  843.  
  844.     i = YRes - 22;
  845.     SFntStClr(Clr);
  846.     SFntStSz(2.0f,2.0f);
  847.     j = (XRes>>1) - (((strlen(s18)) >> 1) * 16);
  848.     SFntStLctn((float)j,(float)i);
  849.     SFntStDrctn(right);
  850.     SFntDsply(s18);
  851.  
  852.     i -= 6;
  853.  
  854.     Line(Wrldxy[0],(float)i,Wrldxy[2],(float)i);
  855.  
  856.     i -= 12;
  857.     Clr++;
  858.     SFntStClr(Clr);
  859.     SFntStSz(1.0f,1.0f);
  860.     j = (XRes>>1) - (((strlen(s19)) >> 1) * 8);
  861.     SFntStLctn((float)j,(float)i);
  862.     SFntStDrctn(right);
  863.     SFntDsply(s19);
  864.  
  865.     if (XRes == 319)
  866.     k = 1;
  867.     else
  868.     k = 2;
  869.  
  870.     i = (YRes>>1)-100;
  871.     Clr++;
  872.     SFntStClr(Clr);
  873.     SFntStSz((float)k,(float)k);
  874.     j = (XRes>>3) - (((strlen(s20)) >> 1));
  875.     SFntStLctn((float)j,(float)i);
  876.     SFntStOrntn(45.0f);
  877.     SFntDsply(s20);
  878.  
  879.     i = (YRes>>1) + 100;
  880.     Clr++;
  881.     SFntStClr(Clr);
  882.     SFntStSz((float)k,(float)k);
  883.     j = (XRes>>1) + (((strlen(s21)) >> 1) );
  884.     SFntStLctn((float)j,(float)i);
  885.     SFntStOrntn(-120.0f);
  886.     SFntDsply(s21);
  887.  
  888.     i -= 275;
  889.     Clr++;
  890.     SFntStClr(Clr);
  891.     SFntStSz((float)k,(float)k);
  892.     j = (XRes>>1) + (((strlen(s22)) >> 1) * (k<<1));
  893.     SFntStLctn((float)j,(float)i);
  894.     SFntStOrntn(-200.0f);
  895.     SFntStDrctn(down);
  896.     SFntDsply(s22);
  897.  
  898.     i += 49;
  899.     Clr++;
  900.     SFntStClr(Clr);
  901.     SFntStSz((float)k,(float)k);
  902.     j = (XRes>>1) + (((strlen(s23)) >> 1) * (k<<4));
  903.     SFntStLctn((float)j,(float)i);
  904.     SFntStOrntn(240.0f);
  905.     SFntStDrctn(up);
  906.     SFntDsply(s23);
  907.  
  908.     getch();
  909. }
  910.