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

📄 svgacc.txt

📁 本程序用于可视化窗口中运行tc下的程序,因为tc2.0不支持粘贴复制等常用的文件操作,不过该系统在输入中文时会有些小问题
💻 TXT
📖 第 1 页 / 共 5 页
字号:
                 if(colr>15)
                    colr = 1;
               }
               drwbox(1,0,x1,y1,x2,y2);
               blkget(x1,y1,x2,y2,gfxblk);
               cntx = (x2-x1) / 2 + x1;
               cnty = (y2-y1) / 2 + y1;
               fillarea(x1+2,y1+2,0,0);
               i = blkrotatesize(45,gfxblk);
               if ( !i ) {
                 restext();
                 printf("ERROR: rotated sprite will be to large");
                 exit(1);
               }
               spritebkgnd = (RasterBlock *)malloc(i);
               if (!spritebkgnd) {
                 restext();
                 printf("ERROR: Allocating memory for spritebkgnd: %d
            bytes\n",i);
                 exit(1);
               }
               gfxblk2 = (RasterBlock *)malloc(i);
               if (!gfxblk2) {
                 restext();
                 printf("ERROR: Allocating memory for gfxblk2: %d
            bytes\n",i);
                 exit(1);
               }
               blkget(x1,y1,x2,y2,spritebkgnd);
               setview(0,64,maxx,maxy);


                                                                         15







               for(i=0;i<=360;i+=3) {
                 rot = blkrotate(i,1,gfxblk,gfxblk2);
                 spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
            (spritebkgnd->height)/2,spritebkgnd);
                 spritegap(1,cntx-(gfxblk2->width)/2,cnty-(gfxblk2-
            >height)/2,gfxblk2,spritebkgnd);
                 sdelay(3);
               }
               spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
            (spritebkgnd->height)/2,spritebkgnd);
               blkput(SET,x1,y1,(RasterBlock *)gfxblk);
               videomodeset(vmode);
               exit(0);
            }










































                                                                         16







          BLKROTATESIZE

            PROTOTYPE

            extern int  far blkrotatesize (int ang, RasterBlock far
            *sourcegfxblk)

            INPUT

            ang - integer degree to rotate source bitmap
            sourcegfxblk - RasterBlock pointer to source bitmap

            OUTPUT

            BLKROTATESIZE returns the number of bytes needed for the
            destination array if successful, 0 if unsuccessful.

            USAGE

            BLKROTATESIZE takes the bitmap in sourcegfxblk and calculates
            the required size of the output buffer needed when BLKROTATE
            is called.  It also insures that the internal library buffers
            are not overflowed.  The function will fail if it calculates
            that the internal buffers would be overflowed or if the
            destination buffer would be larger than 65536 bytes.
            BLKROTATESIZE should be called prior to BLKROTATE to insure
            that buffer integrity is maintained.

            SEE ALSO

            BLKGET, BLKPUT, BLKRESIZE, BLKROTATE

            EXAMPLE

            See BLKROTATE





















                                                                         17







          BYTECOPY

            PROTOTYPE

            extern void far bytecopy (void far *src, void far *dst, long
            numbytes)

            INPUT

            src - pointer to array to be copied
            numbytes - number of bytes to copy from src (<65536)

            OUTPUT

            no value returned
            dst - copy of array

            USAGE

            BYTECOPY copies the specified number of bytes from src to dst.
            It assumes that space for dst has been properly allocated.  It
            is much faster than using a FOR loop or MEMCPY.

            SEE ALSO

            PALCOPY

            EXAMPLE

            /*
             * show byte copy
             */
            #include <stdlib.h>
            #include <conio.h>
            #include "svgacc.h"

            void main(void)
            {
               int i;
               int test1[10], test2[10];

               for(i=0;i<10;i++)
               {
                 test1[i] = i;
               }
               bytecopy(test1,test2,sizeof(test1));
               printf("ok...we initialized one array with data, copied
            that\n");
               printf("array to an a new array...here are the results:\n");
               printf(" \n");
               printf("source array         destination array\n");
               for(i=0;i<10;i++)
               {
                 printf(" %d                    %d\n",test1[i],test2[i]);


                                                                         18







               }
               exit(0);
            }





















































                                                                         19







          D2ROTATE

            PROTOTYPE

            extern void far d2rotate (int points, int xorigin, int
            yorigin, int ang, D2Point far *inary, D2Point far *outary)

            INPUT

            numpoints - number of points to be rotated
            xorigin, yorigin - center of rotation
            angle - angle of rotation about center
            inary - D2Point pointer to array containing points to rotate

            OUTPUT

            no value returned
            outary - D2Point array of rotated values

            USAGE

            D2ROTATE takes the two dimensional points given in inary and
            rotates them by the specified angle about xorigin, yorigin.
            The results are returned in outary which can be the same as
            inary.  A positive angle causes a clockwise rotation on the
            screen, from the positive X axis to the positive Y axis.  The
            function assumes space for outary has been properly allocated.

            SEE ALSO

            D2SCALE, D2TRANSLATE

            EXAMPLE

            /*
             * shows d2rotate 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();


                                                                         20







               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=0;i<=360;i+=2)
               {
                 d2rotate(3,0,0,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;
            }














                                                                         21







          D2SCALE

            PROTOTYPE

            extern void far d2scale (int points, int scalex, int scaley,
            D2Point far *inary, D2Point far *outary)

            INPUT

            numpoints - number of points to scale
            scalex - scale factor along X axis
            scaley - scale factor along Y axis
            inary - D2Point pointer to array containing points to scale

            OUTPUT

            no value returned
            outary - D2Point array of scaled values

            USAGE

            D2SCALE multiplies each coordinate in the two dimensional
            array inary by the corresponding scale factor scalex or
            scaley.  The results are stored in outary which can be the
            same as inary.  A scale factor of 256 (100 hex) is considered
            100 percent and results in no change.  Therefore, 128 (80 hex)
            reduces values by one half and 512 (200 hex) doubles values.
            The function assumes space for outary has been properly
            allocated.

            SEE ALSO

            D2ROTATE, D2TRANSLATE

            EXAMPLE

            /*
             * 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;


                                                                         22








               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)

⌨️ 快捷键说明

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