home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / UTILITIE / CHAOS.ZIP / CHAOS3.C < prev    next >
Text File  |  1989-03-21  |  1KB  |  70 lines

  1. #include "stdio.h"
  2. #include "math.h"
  3. #include "graph.h"
  4.  
  5. struct POINT {
  6.     int x;
  7.     int y;
  8. };
  9.  
  10.  
  11. main()
  12.  
  13. {
  14.     struct  POINT   point[20];
  15.     struct  POINT   halfp;
  16.     long    int     counter;
  17.     int     r_corner;
  18.     int     num;
  19.     double   points;
  20.  
  21.  
  22.     double pie = 3.141593;
  23.     double c;
  24.     int   i   = 0;
  25.  
  26.     system("CLS");
  27.     printf("Enter the number of points to define the object: ");
  28.       if (scanf("%d", &num) == 0)
  29.         exit();
  30.  
  31.     points = (double) num;
  32.  
  33.  
  34.     _setvideomode(_VRES16COLOR);
  35.     _setcolor(4);
  36.  
  37.     for (c = 0; c < (pie * 2.0); c += (pie * 2.0) / points) {
  38.         point[i].x = (int) (320.0 + (sin(c) * 220.0));
  39.         point[i].y = (int) (240.0 + (cos(c) * 220.0));
  40.         i++;
  41.     }
  42.  
  43.  
  44.     for (counter=0; counter<3; counter++)
  45.         _setpixel(point[counter].x, point[counter].y);
  46.  
  47. #if FALSE
  48.     halfp.x = rand() % 640;
  49.     halfp.y = rand() % 480;
  50. #endif
  51.     halfp.x =  320;
  52.     halfp.y =  240;
  53.  
  54.     _setpixel(halfp.x, halfp.y);
  55.  
  56.     for (counter=0; counter<200000; counter++) {
  57.         r_corner = rand() % num;
  58.         halfp.x = (halfp.x + point[r_corner].x) / 2;
  59.         halfp.y = (halfp.y + point[r_corner].y) / 2;
  60.  
  61.         _setpixel(halfp.x, halfp.y);
  62.  
  63.      }
  64.  
  65.  
  66.  
  67.     getch();
  68.     _setvideomode(_DEFAULTMODE);
  69. }
  70.