词条 | D2SCALE |
释义 | 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[3]; D2Point trio[3]; D2Point tri2[3]; 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[0].x = 0; trio[0].y = 0; trio[1].x = -80; trio[1].y = 60; trio[2].x = 80; trio[2].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[0].x,tri2[0].y,tri2[1].x,tri2[1].y); drwline(1,10,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y); drwline(1,10,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y); return; } void ertri(void) { d2translate(3,320,240,tri,tri2); drwline(1,0,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y); drwline(1,0,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y); drwline(1,0,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y); return; } |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。