home *** CD-ROM | disk | FTP | other *** search
/ MS DOS Archives 1 / MS-DOS_Archives_Volume_One_Walnut_Creek.iso / msdos / graphics / hgrph101.arc / COP.C < prev    next >
C/C++ Source or Header  |  1989-02-25  |  2KB  |  59 lines

  1.  
  2.  
  3.  
  4.           /* CORNUCOPIA -- see article on "pseudo-hidden line removal" */
  5.           /* IBM-PC Exchange, May-June 1986 */
  6.  
  7.           #include <math.h>
  8.           #include <conio.h>
  9.           #include "hgraph.h"
  10.  
  11.           main()
  12.           {
  13.  
  14.                int d, a0, b0, a1, b1, a, b;
  15.                double r, rada, radb;
  16.  
  17.                hgraph_init();
  18.                hgmode_nc();
  19.                hclearpg();
  20.                hshowpg();
  21.                hstr(40, 1, " CORNUCOPIA ", 0xff, 12);
  22.                for (d = 1; d <= 100; ++d)
  23.                {
  24.                      rada = (float)d;
  25.                      radb = 0.65 * rada;
  26.                      a0 = 20 + 4 * d;
  27.                      b0 = 20 + 2 * d + (int)(radb * 0.6 * sin(d/10.0));
  28.                      hline(0, a0, b0, a1 = a0, b1 = b0 + (int)radb);
  29.                      for (r = 0.0; r < 6.3; r += 6.28/40.0)
  30.                      {
  31.                            a = a0 + (int)(rada * sin(r));
  32.                            b = b0 + (int)(radb * cos(r));
  33.                            hline(1, a1, b1, a, b);
  34.                            hline(0, a0, b0, a1 = a, b1 = b);
  35.                       }
  36.                }
  37.  
  38.                /*  This next section flips back and forth from
  39.                 *  text to graphics three time to show the use of the
  40.                 *  non-clearing hgmode_nc & htmode_nc the user must hit a
  41.                 *  key to cause the flip
  42.                 */
  43.  
  44.                hstr(10, 40, "Press any key to continue ... ", 0x00, 30);
  45.                   getch();
  46.                htmode_nc();
  47.                   puts("Press any key to continue ... ");
  48.                   getch();
  49.                hgmode_nc(); hshowpg();
  50.                   getch();
  51.                htmode_nc();
  52.                   getch();
  53.                hgmode_nc(); hshowpg();
  54.                   getch();
  55.                htmode();            /* this will clear the text screen */
  56.           }
  57.  
  58.  
  59.