home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / PLOT / PLOT3D_A.ZIP / GRAPH.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-24  |  1.8 KB  |  85 lines

  1. /*
  2.  
  3. Plot3d -- graph.c, the graphics code
  4.  
  5. By Adrian Mariano -- adrian@milton.u.washington.edu
  6.  
  7.  
  8. Copyright (c) 1991 by Adrian Mariano
  9.  
  10. You may use and distribute this program as much as you like so long as you do 
  11. not charge for this service.  I am not liable for failure of this program to 
  12. perform in any way.  
  13.  
  14. */
  15.  
  16.  
  17. #include <graphics.h>
  18. #include <conio.h>
  19. #include <dos.h>
  20.  
  21.  
  22. int returnmode, maxx, maxy, mode;
  23.  
  24. /* This function should return to text mode from graphics mode */
  25.  
  26. void backtotext()
  27. {
  28.    restorecrtmode();
  29.    textmode(returnmode);
  30. }
  31.  
  32.  
  33. /* Enter graphics mode from text mode */
  34.  
  35. void entergraphics()
  36. {
  37.    setgraphmode(mode);
  38.    cleardevice();
  39.    setfillstyle(1, 0);        /* Sections will be black filled */
  40. }
  41.  
  42.  
  43. /* Do graphics initialization, including setting maxx and maxy to the
  44.    maximum x and y values */
  45.  
  46. void initgraphics()
  47. {
  48.    int mm, driver = DETECT;
  49.    char *path;
  50.    struct text_info ti;
  51.    gettextinfo(&ti);
  52.    if (ti.screenheight == 50 || ti.screenheight == 43)
  53.       returnmode = C4350;
  54.    else
  55.       returnmode = C80;
  56.    path = "";
  57.    detectgraph((int far *) (&driver), (int far *) (&mode));
  58.    initgraph((int far *) (&driver), (int far *) (&mode), (char far *) (path));
  59.    if ((mm = graphresult()) != grOk) {
  60.       printf("Error: %d\n", mm);
  61.       exit(0);
  62.    }
  63.    maxx = getmaxx();
  64.    maxy = getmaxy();
  65.    backtotext();
  66. }
  67.  
  68.  
  69. /* Draw the quadrilateral specified by the four coordinate pairs, filled
  70.    in with a different color than the boundaries are drawn in */
  71.  
  72. #pragma argsused
  73.  
  74. void fill(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
  75. {
  76.    fillpoly(4, MK_FP(_SS, &x1));
  77. }
  78.  
  79. /* Draw a line */
  80.  
  81. void drawline(int x1, int x2, int x3, int x4)
  82. {
  83.    line(x1, x2, x3, x4);
  84. }
  85.