DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 967,611 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Mr.Ousi
Mr.Ousi

Posted on

Generation of pieslice without using library function in C.

I was given an assignment to make a "pieslice" using the "graphics.h" header file of the BGI library of C,but without using the built-in function "pieslice()" of that header file.
I used the parametric equation of circle,but unable to generate the figure using the graphics.h function. Some help would be nice. Thank you in advance.
My code so far:

include

include

static const double PI =3.141592

int main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,NULL);
int xc,yc,r,st_angle,ed_angle,k;
printf("Enter the centers of pieslice:\n");
scanf("%d %d",&xc,&yc);
printf("Enter the radius:\n");
scanf("%d",&r);
printf("Enter the starting angle:\n");
scanf("%d",&st_angle);
printf("Enter the end angle:\n");
scanf("%d",&ed_angle);

for(k=st_angle; k<=ed_angle;k++)
{   
    double radians =(PI /180.0) * k;
    int X = xc+ cos(radians) * r;
    int Y = yc+ sin(radians) * r;
    putpixel(x,y,WHITE);
    delay(5000);

}

void wait_for_char()
{

//Wait for a key press
int in = 0;

while (in == 0) {
    in = getchar();
}

}
getch();
}

While running the code[i am using gcc compiler of Ubuntu 16.0.4],i am encountering these errors:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
a.out: ../../src/xcb_io.c:274: poll_for_event: Assertion !xcb_xlib_threads_sequence_lost' failed.
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
a.out: ../../src/xcb_io.c:274: poll_for_event: Assertion
!xcb_xlib_threads_sequence_lost' failed.
Aborted (core dumped)

Top comments (0)

🌚 Life is too short to browse without dark mode