D2SCALE

in in t

DOS SVGACC圖形開發庫函式
原型 extern void far d2scale (int points, int ScaleX, int scaley,D2Point far *inary, D2Point far *outary)
輸入 scalex - X向縮放因子
scaley - Y向縮放因子
inary - 指向原圖形的點數組的D2Point型指針
輸出 無返回值
outary - 指向縮放後圖形的點數組的D2Point型指針
用法 D2SCALE將二維數組inary中的每個坐標乘以相應的縮放因子。結果通過outary返回,outary可與inary共用一個空間。縮放因子為256(100hex)被認為是100%,結果無變化。同理,128(80hex)被認為縮小一半;512(200hex)則為放大一倍。此函式假定outary已合適分配.
例子
/*
* shows d2scale works
*/
#include <stdlib.h>
#include <conio.h>
#include "svgacc.h"
D2Point tri&#91;3&#93;;
D2Point trio&#91;3&#93;;
D2Point tri2&#91;3&#93;;
void drwtri(void);
void ertri(void);
void main(void)
{
int vmode,i;
vmode = videomodeget();
if (!whichvga())
exit(1);
if (whichmem()<512)
exit(1);
res640();
trio&#91;0&#93;.x = 0;
trio&#91;0&#93;.y = 0;
trio&#91;1&#93;.x = -80;
trio&#91;1&#93;.y = 60;
trio&#91;2&#93;.x = 80;
trio&#91;2&#93;.y = 60;
drwtri();
for(i=256;i<=512;i+=4)
{
d2scale(3,i,i,trio,tri);
drwtri();
sdelay(2);
ertri();
}
for(i=512;i>=128;i-=4)
{
d2scale(3,i,i,trio,tri);
drwtri();
sdelay(2);
ertri();
}
for(i=128;i<=256;i+=4)
{
d2scale(3,i,i,trio,tri);
drwtri();
sdelay(2);
ertri();
}
drwtri();
getch();
videomodeset(vmode);
exit(0);
}
void drwtri(void)
{
D2TRANSLATE(3,320,240,tri,tri2);
DRWLINE(1,10,tri2&#91;0&#93;.x,tri2&#91;0&#93;.y,tri2&#91;1&#93;.x,tri2&#91;1&#93;.y);
drwline(1,10,tri2&#91;1&#93;.x,tri2&#91;1&#93;.y,tri2&#91;2&#93;.x,tri2&#91;2&#93;.y);
drwline(1,10,tri2&#91;2&#93;.x,tri2&#91;2&#93;.y,tri2&#91;0&#93;.x,tri2&#91;0&#93;.y);
return;
}
void ertri(void)
{
d2translate(3,320,240,tri,tri2);
drwline(1,0,tri2&#91;0&#93;.x,tri2&#91;0&#93;.y,tri2&#91;1&#93;.x,tri2&#91;1&#93;.y);
drwline(1,0,tri2&#91;1&#93;.x,tri2&#91;1&#93;.y,tri2&#91;2&#93;.x,tri2&#91;2&#93;.y);
drwline(1,0,tri2&#91;2&#93;.x,tri2&#91;2&#93;.y,tri2&#91;0&#93;.x,tri2&#91;0&#93;.y);
return;
}

熱門詞條

聯絡我們