21xrx.com
2024-04-23 15:40:51 Tuesday
登录
文章检索 我的文章 写文章
C 中的 Getarcoords 函数
2021-07-07 18:24:10 深夜i     --     --
C e t a r c o o r d s

声明: void getarccoords(struct arccoordstype *var);

getarccoords 函数用于获取最近绘制的弧的坐标。 arccoordstype 是一个预定义的结构,定义如下:

struct arccoordstype
{
   int x, y;                /*   center point of arc    */
   int xstart, ystart;      /*   start position         */
   int xend, yend;          /*   end position           */
};

arccoordstype 类型的结构变量的地址被传递给函数 getarccoords。

getarccords 的 C 程序

#include<graphics.h>
#include<conio.h>
#include<stdio.h>


main()
{
   int gd = DETECT, gm;
   struct arccoordstype a;
   char arr[100];

   initgraph(&gd, &gm,"C:\\TC\\BGI");

   arc(250,200,0,90,100);
   getarccoords(&a);

   sprintf(arr,"(%d, %d)",a.xstart,a.ystart);
   outtextxy(360,195,arr);

   sprintf(arr,"(%d, %d)",a.xend,a.yend);
   outtextxy(245,85,arr);

   getch();
   closegraph();
   return 0;
}

在程序中,我们已经绘制了一个圆弧,然后我们使用 getarccoords 获取其端点的坐标。 使用 outtextxy 显示如此获得的坐标。

  
  

评论区

{{item['qq_nickname']}}
()
回复
回复