|
主题 : : 看到一个简单的c图形程序,秀秀 [待解决] |
回复[ 18次 ]
点击[ 2613次 ] | |
荣誉值:169
信誉值:0
注册日期:2008-08-19 16:07 |
/*
3DBX.C 画立体块
*/
#include "conio.h"
#include "graphics.h"
void InitGra(void);
void FillScr(void);
void Intfac1(void);
void Intfac2(void);
void Intfac3(void);
void Intfac4(void);
void Box1(int x, int y, int l, int h);
void Box2(int x, int y, int l, int h);
void Box3(int x, int y, int l, int h);
void Box4(int x, int y, int l, int h);
int main(void)
{
InitGra();
FillScr(); Intfac1();
getch();
FillScr(); Intfac2();
getch();
FillScr(); Intfac3();
getch();
FillScr(); Intfac4();
getch();
closegraph() ; return(0);
}
void InitGra(void)
{
int GraphMode, DraphDrive = DETECT;
registerbgidriver(EGAVGA_driver) ;
initgraph(&DraphDrive, &GraphMode, "") ;
}
void FillScr(void)
{
setfillstyle(1, 7);
bar(0, 0, 639, 479);
}
void Intfac1(void)
{
int x, y, l, h, i, j;
y = 5;
l = 45; h = 25;
for (j = 0; j < 13; j++)
{
x = 6;
for (i = 0; i < 11; i++)
{
Box1(x, y, l, h);
x = x+l+13;
}
y = y+h+12;
}
}
void Intfac2(void)
{
int x, y, l, h, i, j;
y = 5;
l = 45; h = 25;
for (j = 0; j < 13; j++)
{
x = 6;
for (i = 0; i < 11; i++)
{
Box2(x, y, l, h);
x = x+l+13;
}
y = y+h+12;
}
}
void Intfac3(void)
{
int x = 0, y = 16;
int l = 639, h = 50;
int i; for (i = 0; i < 6; i++)
{
Box3(x, y, l, h);
y = y+h+40;
}
}
void Intfac4(void)
{
int x = 0, y = 16;
int l = 639, h = 50;
int i; for (i = 0; i < 6; i++)
{
Box4(x, y, l, h);
y = y+h+40;
}
}
void Box1(int x, int y, int l, int h)
{
setcolor(15);
line(x, y, x+l, y);
line(x, y, x, y+h);
setcolor(8);
line(x+l, y+h, x+l, y);
line(x+l, y+h, x, y+h);
}
void Box2(int x, int y, int l, int h)
{
setcolor(8);
line(x, y, x+l, y);
line(x, y, x, y+h);
setcolor(15);
line(x+l, y+h, x+l, y);
line(x+l, y+h, x, y+h);
}
void Box3(int x, int y, int l, int h)
{
setcolor(15);
line(x, y, x+l, y);
line(x+1, y+1, x+l-1, y+1);
setcolor(8);
line(x, y+h, x+l, y+h);
line(x, y+h-1, x+l, y+h-1);
}
void Box4(int x, int y, int l, int h)
{
setcolor(8);
line(x, y, x+l, y);
line(x+1, y+1, x+l-1, y+1);
setcolor(15);
line(x, y+h, x+l, y+h);
line(x, y+h-1, x+l, y+h-1);
} | | |