BGI ライブラリの「graphics.h」ヘッダーには、そのヘッダー ファイルに関数piesliceがあり、その構文は次のとおりです。
#include <graphics.h>
void pieslice(int x, int y, int stangle, int endangle, int radius);
[x,y は円の中心、stangle と endangle はそれぞれ開始角度と終了角度]
BGI ライブラリの組み込み関数を使用せずに、C/C++ でパイスライスを作成できますか。助けてください。線と中点円の生成アルゴリズムを使って作ってみました。
これまでの私のコード:
#include<stdio.h>
#include<graphics.h>
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();
}
円のパラメトリック方程式を使った計算部分はできましたが、関数を使って図形を生成することができませんでしたgraphics.h
。いくつかの助けがいいでしょう。前もって感謝します。
このプログラムの実行中に、次のエラーが発生します。
[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)