C言語でグラフィックス | ||
【2】図形の描画と消去 |
(9)だ円・円(GWellipse関数)
サンプルプログラム 〔gr210.c〕
だ円・円を描画するプログラムを作成する。
#include <GrWin.h> int main(void) { int width = 640, height = 400; GWopen(0); GWsize(-5, &width, &height); GWsize(-3, NULL, NULL); GWvport(0.0, 0.0, (float)width / (float)height, 1.0); GWindow(0.0, 0.0, (float)width - 1.0, (float)height - 1.0); /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ GWclear(-1); GWellipse(50.0, 350.0, 100.0, 250.0); /* だ円描画 */ GWellipse(150.0, 350.0, 250.0, 250.0); /* 円描画 */ /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ GWquit(); return 0; }
int GWellipse(float X1, float Y1, float X2, float Y2); |
(10)円弧(GWarc関数、GWchord関数、GWpie関数)
サンプルプログラム 〔gr211.c〕
円弧を描画するプログラムを作成する。
#include <GrWin.h> int main(void) { int width = 640, height = 400; GWopen(0); GWsize(-5, &width, &height); GWsize(-3, NULL, NULL); GWvport(0.0, 0.0, (float)width / (float)height, 1.0); GWindow(0.0, 0.0, (float)width - 1.0, (float)height - 1.0); /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ GWclear(-1); GWarc(50.0, 350.0, 100.0, 250.0, 0.0, 90.0/360.0); /* 円弧描画 */ GWarc(150.0, 350.0, 250.0, 250.0, 270.0/360.0, 180.0/360.0); /* 円弧描画 */ /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ GWquit(); return 0; }
int GWarc(float X1, float Y1, float X2, float Y2, float 開始角, float 角度量); |
サンプルプログラム 〔gr212.c〕
閉じた円弧を描画するプログラムを作成する。
#include <GrWin.h> int main(void) { int width = 640, height = 400; GWopen(0); GWsize(-5, &width, &height); GWsize(-3, NULL, NULL); GWvport(0.0, 0.0, (float)width / (float)height, 1.0); GWindow(0.0, 0.0, (float)width - 1.0, (float)height - 1.0); /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ GWclear(-1); GWchord(50.0, 350.0, 100.0, 250.0, 0.0, 90.0/360.0); /* 閉じた円弧描画 */ GWpie(150.0, 350.0, 250.0, 250.0, 45.0/360.0, 90.0/360.0); /* 扇形描画 */ /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ GWquit(); return 0; }
int GWchord(float X1, float Y1, float X2, float Y2, float 開始角, float 角度量); |
int GWpie(float X1, float Y1, float X2, float Y2, float 開始角, float 角度量); |
Copyright © 2005 Hiroshi Masuda |