⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 主函数.txt

📁 计算机图形学课程设计,简单图形生成演示.希望对别人有用
💻 TXT
字号:
main()
{
   int select,i,j,radius,bound;
   int x[10],y[10];
   int x1,y1,x2,y2;
   int x_seed, y_seed;
   char ch;
   int driver,mode;
   driver=DETECT;
   mode=0;
   printf("*******1----------draw line*************\n");
   printf("*******2----------draw circle***********\n");
   printf("*******3----------draw mul_boundary*****\n");
   scanf("%d",&select);
   if(select==1)
   {
	   printf("      A/a----------midpoint              \n");
	   printf("      B/b----------DDA                    \n");
	   printf("      C/c----------Bresenham              \n");
	   getchar();
	   ch=getchar();
	   if(ch=='A'||ch=='a')
	   {
		   printf("input start and end point\n");
		   scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		   initgraph(&driver,&mode,"");
		   setcolor(15);
		   set_net(10,10);
		   MidPointLine(x1,y1,x2,y2,10);
	   }
	  if(ch=='B'||ch=='b')
	  {
		  printf("input start and end point\n");
		   scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		   initgraph(&driver,&mode,"");
		   setcolor(15);
		   set_net(10,10);
		   dda_line(x1,y1,x2,y2,10);
	  }
	  if(ch=='C'||ch=='c')
	  {
		  printf("input start and end point\n");
		   scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		   initgraph(&driver,&mode,"");
		   setcolor(15);
		   set_net(10,10);
		   bresenham_line(x1,y1,x2,y2,10);
	  }
   }
   if(select==2)
   {
	   printf("      A/a----------bresenham circle       \n");
	   printf("      B/b----------midpoint circle     \n");
	   getchar();
	   ch=getchar();
	   if(ch=='A'||ch=='a')
	   {
		  printf("input 1 point and the radius:\n");
		   scanf("%d%d%d",&x1,&y1,&radius);
		   initgraph(&driver,&mode,"");
		   setcolor(15);
		   set_net(10,10);
		   bresenham_circle(x1,y1,radius,13);
	  }
	  if(ch=='B'||ch=='b')
	  {
	       printf("input the radius:\n");
	       scanf("%d",&radius);
		MidPointCircle(radius ,13);

	  }
   }
  if(select==3)
  {
    printf("input the point in total=");
    scanf("%d",&bound);
    for(i=0;i<bound;i++)
      {
	printf("input the %d point =",i+1);
	scanf("%d%d",&x[i],&y[i]);
      }
	printf("whether fill the mul_boundary(Y/N):");
    getchar();
	ch=getchar();
	if(ch=='y'||ch=='Y')
	{
		printf("input seed point:");
		scanf("%d%d",&x_seed, &y_seed);
	}
   initgraph(&driver,&mode,"");
   setcolor(15);
   set_net(10,10);
   for(i=0;i<bound-1;i++)
     dda_line(x[i],y[i],x[i+1],y[i+1],13);
   if(ch=='y'||ch=='Y')seed_filling (x_seed, y_seed, 10, 13);
   else exit(0);
  }
   getch();
   restorecrtmode();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -