home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / leda / prog / graphics / inside.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  780 b   |  54 lines

  1. #include <LEDA/window.h>
  2.  
  3. main()
  4.  
  5. { window W;
  6.  
  7.  
  8.   string   s[5];
  9.  
  10.   s[0] = "no grid ";
  11.   s[1] = "10 pixel";
  12.   s[2] = "20 pixel";
  13.   s[3] = "30 pixel";
  14.   s[4] = "40 pixel";
  15.  
  16.   int grid_width = 10 * W.read_panel("GRID MODE ? ",5,s);
  17.  
  18.   W.clear();
  19.  
  20.   W.init(0,1000,0, grid_width);
  21.   W.set_node_width(2);
  22.  
  23.  
  24.   polygon P;
  25.  
  26.   W >> P;
  27.  
  28.   W << P;
  29.  
  30.   int key;
  31.  
  32.   real x,y;
  33.  
  34.   while ((key = W.read_mouse(x,y)) !=3) 
  35.   { point p(x,y);
  36.     W << p; 
  37.     if (key == 1)
  38.     { if (P.inside(p)) W.draw_text(p,"INSIDE");
  39.       else W.draw_text(p,"OUTSIDE");
  40.      }
  41.     else
  42.     { W.clear();
  43.       W << P; 
  44.       int n = W.read_int("n = ");
  45.       while (n--)
  46.       { p = point(random(0,1000),random(0,1000));
  47.         if (P.inside(p)) W.draw_filled_node(p);
  48.         else W << p;
  49.        }
  50.      }
  51.   }
  52.  
  53. }
  54.