C言語でグラフィックス | ||
【2】図形の描画と消去 |
(12)閉じた領域の塗りつぶし(GWflood関数)
◆サンプルプログラム 〔gr215.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); GWsetpen(16, -1, 10, -1); GWrect(50, 350, 250, 150); GWellipse(100, 300, 200, 200); GWsetbrs(13, 1, 1); GWflood(60, 340); /* 塗りつぶし */ /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ GWquit(); return 0; }
int GWflood(float X, float Y); |
(13)点(GWsetpxl関数)
◆サンプルプログラム 〔gr216.c〕◆
複数の点を描画するプログラムを作成する。
#include <GrWin.h> int main(void) { int width = 640, height = 400; int n; 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); for(n = 1; n < 11; ++n){ GWsetpxl(n * 10.0, 400 - n * 10.0, 13); /* 点の描画 */ GWsetpxl(n * 10.0 + 1, 400 - n * 10.0, 13); /* 点の描画 */ } /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ GWquit(); return 0; }
int GWsetpxl(float X, float Y, int 色番号); |
int GWgetpxl(float X, float Y); |
Copyright © 2005 Hiroshi Masuda |