C言語でグラフィックス | ||
【2】図形の描画と消去 |
(7)角の丸い四角形(GWrrect関数)
サンプルプログラム 〔gr208.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); GWsetbrs(13, 1, 1); GWrrect(50.0, 350.0, 100.0, 250.0, 10.0, 10.0); /* 角の丸い四角形描画 */ GWsetbrs(16, 2, 1); GWrrect(150.0, 350.0, 200.0, 250.0, 20.0, 20.0); /* 角の丸い四角形描画 */ /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ GWquit(); return 0; }
int GWrrect(float X1, float Y1, float X2, float Y2, float W, float H); |
(8)塗りつぶしの四角形(GWsrect関数)
サンプルプログラム 〔gr209.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); GWsrect(50.0, 350.0, 100.0, 250.0, 13); /* 塗りつぶしの四角形描画 */ GWsrect(150.0, 350.0, 200.0, 250.0, 16); /* 塗りつぶしの四角形描画 */ /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ GWquit(); return 0; }
int GWsrect(float X1, float Y1, float X2, float Y2, int 色番号); |
Copyright © 2005 Hiroshi Masuda |