PLOY01.C
上传用户:dzj2008
上传日期:2013-03-27
资源大小:94k
文件大小:1k
源码类别:

分形几何

开发平台:

Visual Basic

  1. #include<conio.h>
  2. #include<stdio.h>
  3. #include<graphics.h>
  4. struct polyvetex{
  5.    int x;
  6.    int y;
  7. };
  8. struct polyvetex outside[7];
  9. struct polyvetex inside[4];
  10. main()
  11. {
  12.    int driver,mode,i;
  13.    driver=DETECT;
  14.    mode=0;
  15.    /*struct polyvetex outside[7];
  16.    struct polyvetex inside[4];*/
  17.    outside[0].x=100;
  18.    outside[0].y=100;
  19.    outside[1].x=300;
  20.    outside[1].y=100;
  21.    outside[2].x=400;
  22.    outside[2].y=200;
  23.    outside[3].x=530;
  24.    outside[3].y=250;
  25.    outside[4].x=600;
  26.    outside[4].y=350;
  27.    outside[5].x=300;
  28.    outside[5].y=380;
  29.    outside[6].x=100;
  30.    outside[6].y=300;
  31.    inside[0].x=160;
  32.    inside[0].y=180;
  33.    inside[1].x=270;
  34.    inside[1].y=180;
  35.    inside[2].x=300;
  36.    inside[2].y=230;
  37.    inside[3].x=180;
  38.    inside[3].y=270;
  39.    initgraph(&driver,&mode,"H:\TC\BGI");
  40.    setbkcolor(WHITE);
  41.    setcolor(RED);
  42.    //line(outside[0].x,outside[0].y,outside[1].x,outside[1].y);
  43.    for(i=0;i<=6;i++)
  44.       line(outside[i%7].x,outside[i%7].y,outside[(i+1)%7].x,outside[(i+1)%7].y);
  45.    setfillstyle(SOLID_FILL,RED);
  46.    floodfill(400,300,RED);
  47.    setcolor(WHITE);
  48.    for(i=0;i<=3;i++)
  49.       line(inside[i%4].x,inside[i%4].y,inside[(i+1)%4].x,inside[(i+1)%4].y);
  50.    setfillstyle(SOLID_FILL,WHITE);
  51.    floodfill(200,200,WHITE);
  52.    getch();
  53.    closegraph();
  54.    return 0;
  55. }