C语言中的弧函数

头文件显示图形。h包含 arc() 函数,它绘制一条中心位于(x,y)且半径给定的圆弧。开始角是角度的起点,结束角是角度的终点。角度的值可以在0到360度之间变化。

null

语法:

void arc(int x, int y, int start_angle,
            int end_angle, int radius);

where,
(x, y) is the center of the arc.
start_angle is the starting angle and 
end_angle is the ending angle.
'radius' is the Radius of the arc.

例如:

Input : x=250, y=250, start_angle = 155, end_angle = 300, radius = 100
Output :
图片[1]-C语言中的弧函数-yiteyi-C++库

Input : x=250, y=250, start_angle = 0, end_angle = 300, radius = 100;
Output :
图片[2]-C语言中的弧函数-yiteyi-C++库

下面是arc()函数的实现:

// C implementation of arc function
#include <graphics.h>
// driver code
int main()
{
// gm is Graphics mode which is
// a computer display mode that
// generates image using pixels.
// DETECT is a macro defined in
// "graphics.h" header file
int gd = DETECT, gm;
// location of the arc
int x = 250;
int y = 250;
// starting angle and ending angle
// of the arc
int start_angle = 155;
int end_angle = 300;
// radius of the arc
int radius = 100;
// initgraph initializes the graphics system
// by loading a graphics driver from disk
initgraph(&gd, &gm, "" );
// arc function
arc(x, y, start_angle, end_angle, radius);
getch();
// closegraph function closes the graphics
// mode and deallocates all memory allocated
// by graphics system
closegraph();
return 0;
}


输出:

图片[3]-C语言中的弧函数-yiteyi-C++库
© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享