51、C语言图形函数的两个例子

例一:

#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。  

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值