⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8-13.c

📁 一本经典书籍--C程序员成长攻略的原代码
💻 C
字号:
#include"stdio.h"
#include"dos.h"

unsigned char far *videomem_init_add=(char far *)0xA0000000L;
void InitGraphMode(int mode)
{
	_AH=0x00;
	_AL=mode;
	geninterrupt(0x10);
}

void DrawHLine(int x1,int x2,int y,int color)     /*画水平线*/
{
	int i,x;
	y=(y<<8)+(y<<6);
	for(x=x1;x<=x2;x++)
		videomem_init_add[y+x]=color;
}

void DrawVLine(int x,int y1,int y2,int color)     /*画竖直线*/
{
	int i,y;
	for(y=y1;y<=y2;y++)
		videomem_init_add[(y<<8)+(y<<6)+x]=color;
}

void DrawRect(int x1,int y1,int x2,int y2,int color) /*画矩形框*/
{
	
	DrawHLine(x1,x2,y1,color);  /*画上下边框*/
	DrawHLine(x1,x2,y2,color);
	DrawVLine(x1,y1,y2,color);  /*画左右边框*/
	DrawVLine(x2,y1,y2,color);
}

void FillRect(int x1,int y1,int x2,int y2,int fill_color) /*填充矩形框*/
{
	int i,j;
	/*以下是用画横线的方法来填充矩形*/
	for(j=y1+1;j<y2;j++)   
		DrawHLine(x1+1,x2-1,j,fill_color);
	/*以下是用二重循环依次给矩形框内每个点添上颜色*/
	/*for(i=x1+1;i<=x2-1;i++)  
	for(j=y1+1;j<=y2-1;j++)
	videomem_init_add[(j<<8)+(j<<6)+i]=fill_color;*/
	
}

main()
{
	InitGraphMode(0x13);         /*进入13H图形模式*/
	DrawRect(100,50,200,100,15);  /*用白色画矩形框*/
	FillRect(100,50,200,100,4);     /*用红色填充矩形框*/
	getch();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -