home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1998 September
/
VPR9809A.ISO
/
FFILLY
/
Chat091
/
draw3d.h
< prev
next >
Wrap
Text File
|
1998-04-21
|
2KB
|
97 lines
//draw3D.h
//長方形を3D風に描きます
//pic :描画するピクチャー番号
//x1,y1,x2,y2 :X座標,Y座標
//color :描画色(BGR各色256段階、0x000000~0xffffff)
//edge :3Dの縁の幅(1~長方形の高さor幅の1/2まで)、デフォルトは4
//cont :縁のコントラスト(パーセント)、デフォルトは40(%)
//type :凸凹の指定(凸=0、凹=1)、デフォルトは凸
int draw3D(int pic,int x1,int y1,int x2,int y2,int color,int edge=4,int cont=40,int type=0){
int dummyPic; //ダミーのピクチャー、終了時に削除されます
int dWidth,dHeight; //ダミーのピクチャーの幅と高さ
int orgR,orgG,orgB; //平面の描画色
int col[]; //縁の描画色
int r,g,b; //縁の描画色のRGB成分
int eCont[]; //縁のコントラスト
int i,temp;
dWidth=x2-x1;
if(dWidth<0){
dWidth=-dWidth;
temp=x2;
x2=x1;
x1=temp;
}
dHeight=y2-y1;
if(dHeight<0){
dHeight=-dHeight;
temp=y2;
y2=y1;
y1=temp;
}
dWidth=dWidth+1;
dHeight=dHeight+1;
if(edge<0||edge*2>dWidth||edge*2>dHeight){ //縁のサイズのチェック
return(-1);
}
if(type!=0&&type!=1){ //typeのチェック
return(-1);
}
//縁の描画色の設定
orgB=color/(256*256);
orgG=(color-orgB*256*256)/256;
orgR=color-orgB*256*256-orgG*256;
dummyPic=CreatePic(pic,dWidth,dHeight);
if(type==0){ //凸のとき
eCont[0]=cont*2;
eCont[1]=cont;
eCont[2]=-cont;
eCont[3]=-cont*2;
}
if(type==1){ //凹のとき
eCont[0]=-cont*2;
eCont[1]=-cont;
eCont[2]=cont;
eCont[3]=cont*2;
}
for(i=0;i<4;i=i+1){
b=orgB*(100+eCont[i])/100;
g=orgG*(100+eCont[i])/100;
r=orgR*(100+eCont[i])/100;
if(b>255)b=255;
if(g>255)g=255;
if(r>255)r=255;
if(b<0)b=0;
if(g<0)g=0;
if(r<0)r=0;
col[i]=b*256*256+g*256+r;
}
//ダミーへの描画
SetLineSize(1);
SetPaintColor(col[1]); //左辺
for(i=0;i<edge;i=i+1){
DrawLine(dummyPic,i,i,i,dHeight-i);
}
SetPaintColor(col[2]); //右辺
for(i=0;i<edge;i=i+1){
DrawLine(dummyPic,dWidth-i-1,i,dWidth-i-1,dHeight-i);
}
SetPaintColor(col[3]); //底辺
for(i=0;i<edge;i=i+1){
DrawLine(dummyPic,i,dHeight-i-1,dWidth-i,dHeight-i-1);
}
SetPaintColor(col[0]); //上辺
for(i=0;i<edge;i=i+1){
DrawLine(dummyPic,i,i,dWidth-i,i);
}
SetPaintColor(color);//平面
DrawRect(dummyPic,edge,edge,dWidth-edge,dHeight-edge);
//ピクチャーへの転送とダミーの削除
MovePic(dummyPic,0,0,dWidth,dHeight,pic,x1,y1);
DelPic(dummyPic);
return(0);
}