inside.c
资源名称:leda.tar.gz [点击查看]
上传用户:gzelex
上传日期:2007-01-07
资源大小:707k
文件大小:1k
源码类别:
数值算法/人工智能
开发平台:
MultiPlatform
- #include <LEDA/plane.h>
- #include <LEDA/window.h>
- main()
- { window W;
- string s[5];
- s[0] = "no grid ";
- s[1] = "10 pixel";
- s[2] = "20 pixel";
- s[3] = "30 pixel";
- s[4] = "40 pixel";
- int grid_width = 10 * W.read_panel("GRID MODE ? ",5,s);
- W.clear();
- W.init(0,1000,0, grid_width);
- W.set_node_width(2);
- polygon P;
- W >> P;
- W << P;
- int key;
- double x,y;
- while ((key = W.read_mouse(x,y)) !=3)
- { point p(x,y);
- W << p;
- if (key == 1)
- { if (P.inside(p)) W.draw_text(p,"INSIDE");
- else W.draw_text(p,"OUTSIDE");
- }
- else
- { W.clear();
- W << P;
- int n = W.read_int("n = ");
- while (n--)
- { p = point(rand_int(0,1000),rand_int(0,1000));
- if (P.inside(p)) W.draw_filled_node(p);
- else W << p;
- }
- }
- }
- return 0;
- }