/* WIN-TC BGI 图形编程模板 */
#include "Conio.h"
#include "graphics.h"
#include "math.h"
#include "stdio.h"
#define closegr closegraph
void initgr(void) /* BGI初始化 */
{
int gd = DETECT, gm = 0; /* 和gd = VGA,gm = VGAHI是同样效果 */
registerbgidriver(EGAVGA_driver);/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */
initgraph(&gd, &gm, "");
}
int main(void)
{
setbkcolor(BLUE);
printf("/n/n/n/n/n/n/n//n/t/t/t/t/tHello,dajie!");
getch();
int a,b;float c;
initgr(); /* BGI初始化 */
a=rand()%360;b=0;
c=3.1415926*a/180 ;
while(1)
{
setcolor(rand()%16);
line(320,240,320+rand()%200*cos(c),240-rand()%200sin(c) );
b++;
if(b>10000) break;
}
printf("byebye!");
getch(); /* 暂停一下,看看前面绘图代码的运行结果 */
closegr(); /* 恢复TEXT屏幕模式 */
return 0;
}
/* WIN-TC BGI 图形编程模板 */
最新推荐文章于 2023-03-26 11:34:38 发布
本文介绍了一个使用BGI(Borland Graphics Interface)进行图形编程的简单示例。该程序通过调用BGI库来初始化图形环境,并绘制了一系列随机角度的线条。通过这个例子,读者可以了解如何设置BGI环境并利用基本的图形函数来创建简单的图形应用。

2474

被折叠的 条评论
为什么被折叠?



