例一:
#include "stdio.h"
#include "conio.h"
#include "graphics.h"
#include "stdlib.h"
#include "math.h"
main()
{
int graphdrv=DETECT;
int graphmode;
initgraph(&graphdrv,&graphmode,"\\tc\\bgi");
setbkcolor(0);
outtextxy(140,50,"I love you forever!");
/* 画心脏*/
setcolor(4);
setfillstyle(1, 4);
sector(250,150,0,180,50,50); /* 上左半圆*/
sector(350,150,0,180,50,50); /* 上右半圆*/
sector(400,150,180,240,200,170);
sector(200,150,300,360,200,170);
setcolor(14);
outtextxy(400,380,"23031 LuoZhiwei");
outtextxy(400,400,"2006-12-14");
while(!kbhit());
closegraph();
}
2、例二:
#include "stdio.h"
#include "conio.h"
#include "graphics.h"
#include "stdlib.h"
#include "math.h"
main()
{
int graphdrv=DETECT;
int graphmode;
int i,x=200,y=220;
initgraph(&graphdrv,&graphmode,"\\tc\\bgi");
setbkcolor(0); /*背景颜色*/
outtextxy(140,50,"tai ji ba gua tu");
circle(300,200,100); /*大圆圈*/
setfillstyle(1,15); /*填充--白色,*/
sector(300,200,0,180,100,100); /* 上半 圆-白*/
sector(250,200,180,360,50,50); /*下1/2小圆-白*/
setfillstyle(1,0);
sector(350,200,0,180,50,50); /*上半圆-黑色覆盖白色*/
setfillstyle(1,15); sector(350,200,0,360,10,10);
setfillstyle(1,0);sector(250,200,0,360,10,10);
setcolor(0);
line(250,200,260,200);
line(300,200,400,200); /* 用黑线覆盖上半圆的白色边框*/
setcolor(15);
line(340,200,360,200);
/*打字署名 */
setcolor(14);
outtextxy(…….);
outtextxy(…….);
while(!kbhit());
closegraph();
}
注:windows系统下,kbhit相当于不阻塞的getch,得到按下的键,头文件conio.h。