How to draw an arc in c graphics?

To draw an arc in c/c++ we will use graphics.h header file,circle( ), and some graphic driver codes to initialize the graphic mode. to understand an arc function and arguments of arc function you have to understand the simple maths behind it.
Here in this source code, you can see an arc( ), there are five arguments are present within arc( ).
so here now you have to pass five arguments within arc function

arc(300,250,180,360,50);

To understand the arc( ) and arguments of arc( ), we will consider the arc( ) like this,

void arc(int x,int y,int a, int b,int r);   or   arc(x,y,a,b,r); 

Here x and y are the coordinate and centre of the arc, where a is the starting angle, and b is the end angle of the arc, and the last arguments r is the radius of the arc.

to understand the starting angle and end angle please have a look on the graph given below.
This is the graphical representation 360* protractor, here you can see the position of all angles.

#include<stdio.h>
#include<graphics.h>
#include<conio.h>
void main( )
{
clrscr( );
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
arc(300,250,180,360,50);
getch( );
closegraph( );
}




If this article is helpful for you then do comment and share it with friends. It will motivate me to write such a learning article for you.

If you wanna give any suggestion and correction regarding this article you are always welcome............

Thank you.........


Comments

Popular posts from this blog

Graphics with c/c++