C言語でグラフィックス | ||
【2】図形の描画と消去 |
(11)多角形(GWpolygon関数)・連続線(GWpolylin関数)
サンプルプログラム 〔gr213.c〕
多角形を描画するプログラムを作成する。
#include <GrWin.h> int main(void) { int width = 640, height = 400; float pt[10]; 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); pt[0] = 50; pt[1] = 350; /* 座標設定 */ pt[2] = 80; pt[3] = 290; pt[4] = 130; pt[5] = 290; pt[6] = 100; pt[7] = 250; pt[8] = 70; pt[9] = 270; GWpolygon(pt, 5, 0); /* 多角形描画 */ /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ GWquit(); return 0; }
int GWpolygon(float *座標の配列, int 座標個数, int 塗りつぶしモード); |
サンプルプログラム 〔gr214.c〕◆
連続線を描画するプログラムを作成する。
#include <GrWin.h> int main(void) { int width = 640, height = 400; float pt[10]; 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); pt[0] = 50; pt[1] = 350; /* 座標設定 */ pt[2] = 80; pt[3] = 290; pt[4] = 130; pt[5] = 290; pt[6] = 100; pt[7] = 250; pt[8] = 70; pt[9] = 270; GWpolylin(pt, 5); /* 連続線描画 */ /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ GWquit(); return 0; }
int GWpolylin(float 座標の配列, int 座標個数); |
Copyright © 2005 Hiroshi Masuda |