home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PIXELD.ZIP / HPCOS2.C < prev    next >
C/C++ Source or Header  |  1989-09-22  |  2KB  |  74 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <conio.h>
  5. #include <string.h>
  6. #define INCL_BASE
  7. #define INCL_NOPM
  8. #include <os2.h>
  9. #include "pixeldll.h"
  10.  
  11. #define  IN_ARG           1
  12. #define  PLOT_ARG         2
  13.  
  14. main (int argc, char *argv [])
  15. {
  16. float pi = (float) 3.14159;
  17. float a,h,b,r,x0,y0,x,y,ang;
  18. int   new_color;
  19. int   bk_color;
  20. int   file_counter;
  21.  
  22. if (argc != 3)
  23.    {
  24.    printf ("\nUSAGE : HPCOS2 <graphfile> <# of graphs>\n");
  25.    exit (0);
  26.    }
  27.  
  28. for (file_counter = 0; file_counter < atoi (argv [PLOT_ARG]); file_counter++)
  29.    {
  30.    printf ("\ncircle ratio (>=1): ");
  31.    scanf ("%f",&r);
  32.    printf ("\npen position > 1): ");
  33.    scanf ("%f",&h);
  34.    printf("\ncolor for graph? : ");
  35.    scanf("%d", &new_color);
  36.    printf("\ncolor for bkgrnd? <works on 1st graph only> : ");
  37.    scanf("%d", &bk_color);
  38.  
  39.    CliOpenVGA ();
  40.  
  41.    if (file_counter)
  42.       {
  43.       if (!PgrRestoreScreenVGA (argv [IN_ARG]))
  44.      {
  45.      CliCloseVGA ();
  46.      printf ("\nCould not restore screen from %s\n", argv [IN_ARG]);
  47.      exit (0);
  48.      }
  49.       }
  50.    else
  51.       {
  52.       PgrClrScrVGA (bk_color);
  53.       }
  54.    x0 = (float) (640/2 - 1);
  55.    y0 = (float) (480/2 - 1);
  56.    a = (float) 0.5*r*480/(r+h-1);
  57.    b = a/r;
  58.    h *= b;
  59.    ang = (float) 0;
  60.    while (!kbhit())
  61.      {
  62.      ang = ang + 2*pi/250;
  63.      x = x0+(a-b)*cos(ang)+h*cos(ang*(a-b)/b);
  64.      y = y0-(a-b)*sin(ang)+h*sin(ang*(a-b)/b);
  65.      PgrGraph (_PIXEL, (SHORT) x, (SHORT) y, new_color);
  66.      }
  67.    PgrSaveScreenVGA (argv [IN_ARG]);
  68.    DosBeep (260, 30);
  69.    CliCloseVGA ();
  70.    }
  71. return (TRUE);
  72. }
  73. /****************************************************************************/
  74.