home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / graph.zip / GRDEMO.C < prev    next >
Text File  |  1987-06-10  |  2KB  |  80 lines

  1. /*--------------------------------------------------------------------
  2.  *                                grdemo.c
  3.  *
  4.  *         illustrates the use of the graphic functions in graph.lib
  5.  *
  6.  *                     copyright 1987 by Michael Allen
  7.  *
  8.  *
  9.  *--------------------------------------------------------------------*/
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <dos.h>
  14. #include "glob_defs.h"
  15. #include "global.h"
  16. #include "graph.h"
  17.  
  18. void
  19. p(int x, int y, char *item)
  20. {
  21.   gotoxy(x, y);
  22.   puts(item);
  23. }
  24.  
  25. main()
  26. {
  27.    register int x, y, i;
  28.  
  29.    hires();
  30.    hirescolor(WHITE);
  31.  
  32.    p(20,8,"testing plot...");
  33.    for (i=0;i < 1500;i++)
  34.       plot(rand() % xmax, rand() % ymax);
  35.    getchar();
  36.  
  37.    p(20,10,"testing draw_line...");
  38.    for (i=0,x = 20;x < 220;x+=6,i++)
  39.       draw_line(x, 1, x+150+i, 190);
  40.    getchar();
  41.    clearscreen();
  42.  
  43.    hirescolor(BLUE);
  44.    p(20,12,"testing draw_box...");
  45.    for (i=0,y = 10,x = 10;x < 350;x+=4,y+=2,i+=2)
  46.       draw_box(x, y, x+50+i, y+25);
  47.    getchar();
  48.    clearscreen();
  49.  
  50.    hirescolor(GREEN);
  51.    p(20,13,"testing draw_circle...");
  52.    for (y = 10,x = 320;y < 100;y+=2)
  53.       draw_circle(320,100, x, y);
  54.    getchar();
  55.    clearscreen();
  56.  
  57.    hirescolor(YELLOW);
  58.    p(20,14,"testing draw_ellipse...");
  59.    for (i = 0,y = 20,x = 150;x < 300;x+=4,y+=2,i+=2)
  60.       lips(x,y,x+150,y+20+i);
  61.    getchar();
  62.  
  63.    hirescolor(CYAN);
  64.    p(20,16,"draw boxes with xor_mode...");
  65.    draw_option = XOR_MODE;
  66.    for (y = 0,x = 150;x < 500;x+=2,y++)
  67.    {
  68.       draw_box(x, y, x + 48, y + 24);
  69.        for (i = 0;i < 1000;i++);         /* pause */
  70.       draw_box(x, y, x + 48, y + 24);
  71.    }
  72.    draw_option = NORMAL;
  73.    draw_box(x, y, x + 48, y + 24);
  74.  
  75.    getchar();
  76.  
  77.    textmode();
  78.  
  79. }
  80.